/* ===================================================================
   Seedream Studio — style.css
   Dark cinematic theme
=================================================================== */

/* ------------------------------------------------------------------ */
/* RESET                                                               */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ------------------------------------------------------------------ */
/* TOAST                                                               */
/* ------------------------------------------------------------------ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-hi);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 10px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------------ */
/* TOKENS                                                              */
/* ------------------------------------------------------------------ */
:root {
  --bg:           #0E0F12;
  --surface:      #16181D;
  --surface-hi:   #1C1F26;
  --line:         #23262E;
  --accent:       #7C5CFF;
  --accent-soft:  rgba(124, 92, 255, 0.14);
  --accent-h:     #9b80ff;
  --text:         #E8EAED;
  --text-dim:     #9097A1;
  --text-muted:   #5A6068;
  --danger:       #E05A5A;
  --success:      #4CAF7D;
  --warning:      #E0A030;
  --radius:       8px;
  --rail-w:       380px;
}

/* ------------------------------------------------------------------ */
/* BASE                                                                */
/* ------------------------------------------------------------------ */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

textarea, input {
  font-family: inherit;
}

/* ------------------------------------------------------------------ */
/* STUDIO LAYOUT                                                       */
/* ------------------------------------------------------------------ */
.studio-layout {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* RAIL (Left sidebar)                                                 */
/* ------------------------------------------------------------------ */
.rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Rail header */
.rail-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.rail-logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rail-logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.logout-btn:hover { color: var(--accent); background: var(--accent-soft); }

.rail-logo-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.rail-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-hi);
  border-radius: 8px;
  padding: 3px;
}

.rail-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.rail-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Rail body */
.rail-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 16px; /* room for content */
}

.rail-body.hidden {
  display: none;
}

/* Scrollbar styling */
.rail-body::-webkit-scrollbar { width: 5px; }
.rail-body::-webkit-scrollbar-track { background: transparent; }
.rail-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ------------------------------------------------------------------ */
/* SECTIONS                                                            */
/* ------------------------------------------------------------------ */
.section {
  padding: 16px 20px 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-num {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--surface-hi);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* PROVIDER SWITCHER                                                   */
/* ------------------------------------------------------------------ */
.provider-switcher {
  display: flex;
  gap: 6px;
}

.provider-btn {
  flex: 1;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 0;
  border-radius: 8px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.provider-btn:hover {
  border-color: var(--accent-soft);
  color: var(--text);
}

.provider-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.provider-error {
  font-size: 12px;
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* PROMPT                                                              */
/* ------------------------------------------------------------------ */
#prompt {
  width: 100%;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  scrollbar-width: none;
}
#prompt::-webkit-scrollbar { display: none; }

#prompt:focus {
  border-color: var(--accent);
}

#prompt::placeholder {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* REFERENSE CARD                                                      */
/* ------------------------------------------------------------------ */
.ref-card {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Mode toggle pill */
.mode-toggle {
  display: flex;
  padding: 6px;
  gap: 4px;
}

.mode-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 0;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Drop zone */
.ref-drop {
  padding: 0 8px 8px;
}

.ref-drop.hidden {
  display: none;
}

.ref-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  transition: border-color 0.15s;
}

.ref-drop.drag-over .ref-empty {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ref-empty svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.ref-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Preview — old single-ref styles kept for compat but replaced by ref-list */
.ref-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
}

.ref-preview.hidden {
  display: none;
}

.ref-preview img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.ref-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ref-filename {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.ref-clear-btn:hover {
  color: var(--danger);
}

/* Multi-ref strip */
.ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
}

.ref-list.hidden {
  display: none;
}

.ref-card-item {
  position: relative;
  width: 68px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  opacity: 1;
  transition: opacity 0.2s;
}

.ref-card-item.uploading {
  opacity: 0.55;
}

.ref-card-item img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  display: block;
}

.ref-card-num {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.55);
  border-radius: 3px;
  padding: 1px 4px;
  pointer-events: none;
}

.ref-card-rm {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.ref-card-rm:hover {
  background: var(--danger);
}

.ref-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0 2px;
}

.ref-hint.hidden {
  display: none;
}

.ref-mode-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0 4px;
}

/* ------------------------------------------------------------------ */
/* WARDROBE / S3 GALLERY                                               */
/* ------------------------------------------------------------------ */
.s3-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 0;
  margin-left: auto;
}

.s3-arrow { display: inline-block; transition: transform 0.2s; }
.s3-arrow.collapsed { transform: rotate(-90deg); }

.s3-gallery-body { margin-top: 6px; }
.s3-gallery-body.collapsed { display: none; }

.s3-gallery-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.s3-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.s3-thumb-wrap:hover {
  border-color: var(--accent-soft);
}

.s3-thumb-wrap.active {
  border-color: var(--accent);
}

.s3-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.s3-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  display: grid;
  place-items: center;
}

.s3-thumb-wrap:hover .s3-del-btn {
  opacity: 1;
}

.s3-show-all {
  margin-top: 8px;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 0;
  transition: background 0.15s, color 0.15s;
}

.s3-show-all:hover {
  background: var(--surface-hi);
  color: var(--text);
}

.s3-show-all.hidden {
  display: none;
}

/* ------------------------------------------------------------------ */
/* ASPECT RATIO GRID                                                   */
/* ------------------------------------------------------------------ */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ratio-btn:hover {
  border-color: var(--accent-soft);
  color: var(--text);
}

.ratio-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.ratio-btn .ratio-rect {
  background: var(--text-dim);
  border-radius: 2px;
  transition: background 0.15s;
}

.ratio-btn.active .ratio-rect {
  background: var(--accent);
}

/* ------------------------------------------------------------------ */
/* QUALITY                                                             */
/* ------------------------------------------------------------------ */
.quality-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quality-option {
  position: relative;
}

.quality-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.quality-card {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quality-option input:checked + .quality-card {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quality-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}

.quality-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ------------------------------------------------------------------ */
/* COUNT                                                               */
/* ------------------------------------------------------------------ */
.count-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.count-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.count-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}

.count-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
}

.count-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.count-val {
  font-size: 15px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  min-width: 28px;
  text-align: center;
}

.count-presets {
  display: flex;
  gap: 4px;
}

.count-preset {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.count-preset:hover {
  border-color: var(--accent-soft);
  color: var(--text);
}

.count-preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

/* ------------------------------------------------------------------ */
/* STICKY CTA                                                          */
/* ------------------------------------------------------------------ */
.rail-cta {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 16px 20px 20px;
}

.gen-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 0;
  border-radius: 10px;
  transition: background 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gen-btn:hover:not(:disabled) {
  background: var(--accent-h);
}

.gen-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.eta-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ------------------------------------------------------------------ */
/* HISTORY PANEL (in canvas)                                          */
/* ------------------------------------------------------------------ */
.canvas-history-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
}

.canvas-history-panel.hidden { display: none; }

/* ------------------------------------------------------------------ */
/* FAVORITES PANEL                                                     */
/* ------------------------------------------------------------------ */
.canvas-favorites-panel {
  height: 100%;
  overflow-y: auto;
  padding: 0 0 16px;
}
.canvas-favorites-panel.hidden { display: none; }

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.fav-grid-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.1s;
}
.fav-grid-item:hover { transform: scale(1.01); }
.fav-grid-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.favorites-empty {
  text-align: center;
  color: var(--text-muted);
  margin-top: 80px;
  font-size: 14px;
}
.favorites-empty.hidden { display: none; }

/* Second tabs row */
.rail-tabs-row2 {
  margin-top: 4px;
}

.history-filters {
  display: flex;
  gap: 6px;
  padding: 0 0 16px;
  flex-shrink: 0;
}

.filter-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 20px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.filter-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

/* History grid in canvas: multi-column cards */
.history-grid-canvas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-content: start;
}

.history-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.history-empty.hidden { display: none; }

/* History card */
.h-card {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.h-thumb-row {
  display: flex;
  gap: 2px;
  max-height: 180px;
}

.h-thumb-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.h-thumb-wrap img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.h-dl-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.h-thumb-wrap:hover .h-dl-btn {
  opacity: 1;
}

.h-meta {
  padding: 10px 12px;
}

.h-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.h-meta-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.badge {
  font-size: 10.5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.h-prompt {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  cursor: pointer;
  margin-bottom: 8px;
}

.h-prompt.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.repeat-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.repeat-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.h-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.h-del-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.h-del-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(224, 90, 90, 0.08);
}

/* ------------------------------------------------------------------ */
/* CANVAS (right)                                                       */
/* ------------------------------------------------------------------ */
.canvas {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* Dot grid background */
.canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.45;
}

.canvas-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  background: rgba(14,15,18,0.85);
  backdrop-filter: blur(8px);
}

.canvas-title-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.status-bar {
  flex: 1;
  font-size: 13px;
  color: var(--text-dim);
}

.status-bar.processing { color: var(--warning); }
.status-bar.done       { color: var(--success); }
.status-bar.error      { color: var(--danger); }

.topbar-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 7px;
  transition: border-color 0.15s, color 0.15s;
}

.topbar-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

/* Canvas body */
.canvas-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
  position: relative;
  z-index: 1;
}

#canvas-generate {
  min-height: 100%;
  position: relative;
}

#canvas-generate.hidden { display: none; }

.canvas-assistant.hidden { display: none; }

.canvas-body::-webkit-scrollbar { width: 5px; }
.canvas-body::-webkit-scrollbar-track { background: transparent; }
.canvas-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* Placeholder */
.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 80px 0;
  pointer-events: none;
}

.ph-icon {
  font-size: 32px;
  color: var(--text-muted);
}

.ph-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dim);
}

.ph-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Results grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.results-grid.single {
  grid-template-columns: 1fr;
  max-width: 500px;
}

/* Result card */
.result-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.result-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Loading skeleton */
.result-card.loading {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Numbered badge */
.result-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Action cluster top-right */
.result-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.15s;
}

.result-card:hover .result-actions {
  opacity: 1;
}

.result-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(124,92,255,0.5);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.result-icon-btn.active,
.result-icon-btn.fav-active {
  color: #ef4444;
  border-color: rgba(239,68,68,0.5);
}

.result-icon-btn:hover {
  background: rgba(30,30,30,0.92);
  transform: scale(1.08);
}

/* Bottom bar */
.result-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.72) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.15s;
}

.result-card:hover .result-bottom {
  opacity: 1;
}

.result-seed {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.result-variation-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.result-variation-btn:hover {
  background: rgba(255,255,255,0.22);
}

/* Disable browser image toolbar (Chrome/Edge download/lens buttons) */
.result-card img {
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.result-card {
  cursor: default;
}

/* Canvas footer */
.canvas-footer {
  border-top: 1px solid var(--line);
  padding: 8px 24px;
  min-height: 36px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
  background: rgba(14,15,18,0.85);
}

/* ------------------------------------------------------------------ */
/* SPINNER                                                             */
/* ------------------------------------------------------------------ */
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* LIGHTBOX                                                            */
/* ------------------------------------------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
}

.lightbox-img-wrap {
  position: relative;
  z-index: 1;
  display: inline-block;
  max-width: 92vw;
  max-height: 90vh;
  line-height: 0;
}

#lightbox-img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.lightbox-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

.lightbox-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(124,92,255,0.5);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: background 0.15s, transform 0.1s;
}
.lightbox-action-btn:hover {
  background: rgba(30,30,30,0.92);
  transform: scale(1.08);
}
.lightbox-action-btn.fav-active {
  color: #ef4444;
  border-color: rgba(239,68,68,0.5);
}

/* ===================================================================
   ASSISTANT TAB — 3-column layout + chat + presets + history
   =================================================================== */

/* ── Panel container ─────────────────────────────────────────────── */
.canvas-assistant {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  height: 100%;
  overflow: hidden;
}

/* ── Shared column base ─────────────────────────────────────────── */
.asst-presets-col,
.asst-chat-col,
.asst-history-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.asst-presets-col  { border-right: 1px solid var(--line); }
.asst-history-col  { border-left:  1px solid var(--line); }

/* ── Presets column ─────────────────────────────────────────────── */
.asst-presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}
.asst-presets-add-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
}
.asst-presets-add-btn:hover { background: var(--accent-soft); }

.asst-presets-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.asst-presets-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Preset card */
.asst-preset-card {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 10px;
  background: var(--surface-hi);
  cursor: pointer;
  position: relative;
  transition: border-color .15s;
}
.asst-preset-card:hover        { border-color: var(--line); }
.asst-preset-card.active       { border-color: var(--accent); background: var(--accent-soft); }
.asst-preset-card:hover .asst-preset-actions { opacity: 1; }

.asst-preset-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.asst-preset-check { accent-color: var(--accent); cursor: pointer; }
.asst-preset-label { font-size: 13px; font-weight: 500; color: var(--text); }
.asst-preset-hint  { font-size: 11px; color: var(--text-muted); margin-top: 3px; margin-left: 22px; }

.asst-preset-actions {
  position: absolute;
  right: 6px;
  top: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.asst-preset-edit,
.asst-preset-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--text-dim);
}
.asst-preset-edit:hover { color: var(--accent); background: var(--accent-soft); }
.asst-preset-del:hover  { color: var(--danger, #ff4d4f); background: rgba(255,77,79,.12); }

/* ── Chat column ────────────────────────────────────────────────── */
.asst-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Empty state */
.asst-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text-dim);
  text-align: center;
  user-select: none;
}
.asst-empty-icon  { font-size: 32px; opacity: .5; }
.asst-empty-title { font-size: 16px; font-weight: 600; }
.asst-empty-sub   { font-size: 13px; color: var(--text-muted); max-width: 340px; }
.asst-empty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 6px;
  max-width: 420px;
}
.asst-sample-chip {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.asst-sample-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Messages */
.asst-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}
.asst-msg-user      { align-self: flex-end; align-items: flex-end; }
.asst-msg-assistant { align-self: flex-start; align-items: flex-start; }

.asst-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.asst-msg-user .asst-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.asst-msg-assistant .asst-msg-bubble {
  background: var(--surface-hi);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.asst-msg-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: inherit;
}
.asst-msg-user .asst-msg-text { font-family: inherit; font-size: 13px; }

.asst-msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.asst-insert-btn,
.asst-copy-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.asst-insert-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.asst-copy-btn:hover   { border-color: var(--line); color: var(--text); }

.asst-msg-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.asst-msg-img {
  max-width: 120px;
  border-radius: 8px;
  margin-bottom: 4px;
  align-self: inherit;
}

/* Thinking dots */
.asst-thinking .asst-msg-bubble { padding: 12px 18px; }
.asst-dots { display: inline-flex; gap: 5px; align-items: center; }
.asst-dots i {
  display: block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: asst-pulse 1.2s ease-in-out infinite;
}
.asst-dots i:nth-child(2) { animation-delay: .2s; }
.asst-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes asst-pulse {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1;  }
}

.asst-msg-error {
  align-self: center;
  background: rgba(255,77,79,.1);
  border: 1px solid rgba(255,77,79,.3);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: #ff6b6b;
}

/* ── Composer ───────────────────────────────────────────────────── */
.asst-composer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.asst-selector-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.asst-selector {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}
.asst-selector:focus { outline: none; border-color: var(--accent); }
.asst-selector-warn {
  font-size: 11px;
  color: var(--danger, #ff4d4f);
  padding: 4px 0;
}

/* Active preset chips */
.asst-active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.asst-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--accent);
}
.asst-chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}

/* Input pill */
.asst-input-pill {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s;
}
.asst-input-pill:focus-within { border-color: var(--accent); }

.asst-attach-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
}
.asst-attach-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.asst-attach-name { font-size: 11px; color: var(--text-dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.asst-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.asst-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 3px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
.asst-icon-btn:hover { color: var(--text-dim); }

.asst-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  padding: 2px 0;
  max-height: 160px;
  overflow-y: auto;
  font-family: inherit;
}
.asst-textarea::placeholder { color: var(--text-muted); }

.asst-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}
.asst-send-btn:disabled { opacity: .35; cursor: not-allowed; }
.asst-send-btn:not(:disabled):hover { opacity: .85; }

.asst-composer-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* ── History column ─────────────────────────────────────────────── */
.asst-hist-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}
.asst-hist-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.asst-hist-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.asst-hist-card {
  position: relative;
  border-radius: 8px;
  background: var(--surface-hi);
  border: 1px solid transparent;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.asst-hist-card:hover { border-color: var(--accent); }
.asst-hist-card-meta  { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.asst-hist-card-text  { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px; }

.asst-hist-del-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s, color .15s;
  line-height: 1;
}
.asst-hist-card:hover .asst-hist-del-btn { opacity: 1; }
.asst-hist-del-btn:hover { color: var(--danger); }

.asst-hist-footer {
  padding: 8px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.asst-hist-all-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  padding: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.asst-hist-all-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modals ─────────────────────────────────────────────────────── */
.asst-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.asst-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 480px;
  max-width: 96vw;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.asst-modal-wide { width: 640px; }
.asst-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.asst-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.asst-modal-close:hover { background: var(--surface-hi); }
.asst-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.asst-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.asst-form-label   { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.asst-form-input, .asst-form-textarea {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.asst-form-input:focus, .asst-form-textarea:focus { border-color: var(--accent); }
.asst-form-textarea { resize: vertical; min-height: 80px; }

.asst-btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.asst-btn-primary:hover { opacity: .85; }
.asst-btn-secondary {
  background: var(--surface-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.asst-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.asst-btn-danger {
  background: none;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.asst-btn-danger:hover { background: var(--danger); color: #fff; }

.asst-hist-preset-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.asst-hist-preset-badge {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.asst-hist-preset-badge:hover { background: var(--accent); color: #fff; }

.asst-all-hist-del {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: color .15s;
  flex-shrink: 0;
}
.asst-all-hist-del:hover { color: var(--danger); }

/* History detail */
.asst-hist-detail-text {
  background: var(--surface-hi);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
}
.asst-hist-detail-reply {
  background: var(--surface-hi);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.asst-hist-detail-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}
.asst-hist-detail-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
}

/* All history rows */
.asst-all-hist-body { padding: 0 !important; }

.asst-refs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.asst-refs-grid-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.asst-refs-grid-item:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}
.asst-refs-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.asst-all-hist-row {
  display: grid;
  grid-template-columns: 120px 100px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s;
  font-size: 12px;
}
.asst-all-hist-row:hover        { background: var(--surface-hi); }
.asst-all-hist-model            { color: var(--text); font-weight: 500; }
.asst-all-hist-dt               { color: var(--text-muted); }
.asst-all-hist-q                { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Prompt textarea highlight when filled from assistant */
.prompt-from-assistant {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft);
  transition: box-shadow .4s ease;
}
