
  :root {
    --bg-primary: #0f0f14;
    --bg-secondary: #18181f;
    --bg-tertiary: #1e1e28;
    --bg-hover: #252532;
    --border: #2a2a3a;
    --border-light: #353548;
    --text-primary: #e8e8ef;
    --text-secondary: #9898ab;
    --text-muted: #5c5c72;
    --accent: #7c5cfc;
    --accent-hover: #6a4ae0;
    --accent-soft: rgba(124,92,252,0.12);
    --red: #ef4444;
    --green: #22c55e;
    --orange: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { background: var(--bg-primary); color: var(--text-primary); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; overflow: hidden; height: 100vh; display: flex; flex-direction: column; }

  /* HEADER */
  .header { height: 40px; background: var(--bg-secondary); display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border); gap: 12px; flex-shrink: 0; }
  .header .logo { font-size: 14px; font-weight: 700; color: var(--accent); }
  .header .sep { width: 1px; height: 18px; background: var(--border); }
  .header .shortcuts { font-size: 11px; color: var(--text-muted); }
  .header .spacer { flex: 1; }
  .header .status { font-size: 11px; color: var(--text-secondary); }
  /* Folder picker button */
  .folder-btn {
    display: flex; align-items: center; gap: 5px; padding: 3px 10px;
    background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-muted); font-size: 10px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all 0.15s;
  }
  .folder-btn:hover { border-color: var(--accent); color: var(--text-secondary); }
  .folder-btn.connected { color: var(--green); border-color: rgba(34,197,94,0.3); }
  .folder-btn.connected svg { stroke: var(--green); }
  /* API keys button */
  .api-keys-btn {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0;
    background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  }
  .api-keys-btn:hover { border-color: var(--accent); color: var(--accent); }
  .api-keys-btn.configured { color: var(--green); border-color: rgba(34,197,94,0.3); }
  .api-keys-btn.configured svg { stroke: var(--green); }
  /* Modal overlay */
  .modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 300; align-items: center; justify-content: center;
  }
  .modal-overlay.active { display: flex; }
  .modal-box {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; width: 420px; max-width: 90vw; box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  }
  .modal-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--text-primary); }
  .modal-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 4px; }
  .modal-input {
    width: 100%; padding: 8px 10px; background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary); font-size: 12px; font-family: monospace;
    margin-bottom: 12px;
  }
  .modal-input:focus { outline: none; border-color: var(--accent); }
  .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
  .modal-btn {
    padding: 8px 20px; border-radius: var(--radius); border: none; font-size: 12px;
    font-weight: 600; cursor: pointer; font-family: inherit;
  }
  .modal-btn.primary { background: var(--accent); color: white; }
  .modal-btn.primary:hover { background: var(--accent-hover); }
  .modal-btn.secondary { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
  .modal-btn.secondary:hover { background: var(--bg-hover); }
  /* Version dropdown */
  .ver-wrap { position: relative; }
  .ver-btn {
    display: flex; align-items: center; gap: 4px; padding: 3px 8px;
    background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--green); font-size: 10px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: all 0.15s;
  }
  .ver-btn:hover { border-color: var(--accent); color: var(--accent); }
  .ver-btn::after { content: none; }
  .ver-btn .hdr-chev { width: 8px; height: 8px; opacity: 0.5; flex-shrink: 0; }
  .ver-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 180px;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 200; padding: 4px 0;
    max-height: 320px; overflow-y: auto;
  }
  .ver-menu.open { display: block; }
  .ver-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px;
    font-size: 11px; color: var(--text-secondary); cursor: pointer; transition: background 0.1s;
  }
  .ver-item:hover { background: var(--bg-hover); color: var(--text-primary); }
  .ver-item.active { color: var(--accent); font-weight: 600; }
  .ver-item .ver-tag { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .ver-item .ver-date { font-size: 9px; color: var(--text-muted); margin-left: auto; }

  /* SESSIONS PANEL (left column) */
  .sessions-panel {
    width: 80px; min-width: 80px; background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 6px; gap: 8px; flex-shrink: 0; overflow: hidden;
  }
  .sessions-panel.expanded { width: 220px; min-width: 220px; }
  .sessions-toggle {
    width: 100%; padding: 4px; background: transparent; border: none;
    color: var(--text-muted); font-size: 10px; font-weight: 600; cursor: pointer;
    text-transform: uppercase; letter-spacing: 0.8px; display: flex;
    align-items: center; justify-content: center; gap: 4px; transition: color 0.15s;
  }
  .sessions-toggle:hover { color: var(--text-primary); }
  .sessions-scroll {
    flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
    padding: 0 0 4px; width: 100%;
  }
  .session-card {
    display: flex; align-items: center; gap: 6px; padding: 4px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); cursor: pointer; flex-shrink: 0;
    width: 100%; transition: all 0.15s; position: relative;
  }
  .session-card.active {
    flex-direction: column; align-items: stretch;
  }
  .session-card.active > .session-card-header {
    display: flex; align-items: center; gap: 6px;
  }
  .session-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
  .session-card.active { border-color: var(--accent); background: var(--accent-soft); }
  .session-card.loading { opacity: 0.5; pointer-events: none; }
  .sessions-panel:not(.expanded) .session-card { flex-direction: column; padding: 4px; gap: 0; justify-content: center; align-items: center; }
  .sessions-panel:not(.expanded) .session-info { display: none; }
  .sessions-panel:not(.expanded) .session-menu-btn { display: none !important; }
  .session-thumb {
    width: 42px; height: 42px; border-radius: var(--radius);
    object-fit: cover; flex-shrink: 0; background: var(--bg-primary);
  }
  .sessions-panel.expanded .session-thumb { width: 42px; height: 42px; }
  .session-info { display: flex; flex-direction: column; gap: 1px; overflow: hidden; flex: 1; }
  .session-name {
    font-size: 11px; font-weight: 500; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .session-meta { font-size: 9px; color: var(--text-muted); white-space: nowrap; }
  .session-menu-btn {
    position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
    border-radius: 4px; background: transparent; border: none;
    color: var(--text-muted); font-size: 11px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
  }
  .session-card:hover .session-menu-btn { display: flex; }
  .session-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
  .session-add-btn {
    width: 100%; height: 36px; border-radius: var(--radius-lg);
    background: var(--accent-soft); border: 1px dashed var(--border);
    color: var(--accent); font-size: 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.15s;
  }
  .session-add-btn:hover { background: var(--accent); color: white; border-style: solid; }
  .session-name-input {
    background: transparent; border: 1px solid var(--accent); color: var(--text-primary);
    font-size: 11px; padding: 1px 4px; border-radius: 3px; outline: none; width: 100%; font-family: inherit;
  }
  .session-loading-overlay {
    position: fixed; inset: 0; background: rgba(15,15,20,0.7); z-index: 200;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: var(--text-primary); gap: 10px;
  }
  /* Context menu */
  .sess-context-menu {
    position: fixed; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 4px 0; z-index: 100; min-width: 140px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  .sess-context-menu div {
    padding: 6px 14px; font-size: 12px; color: var(--text-primary); cursor: pointer; transition: background 0.1s;
  }
  .sess-context-menu div:hover { background: var(--bg-hover); }
  .sess-context-menu div.danger { color: var(--red); }
  .sess-context-menu div.danger:hover { background: rgba(239,68,68,0.1); }

  /* MAIN AREA */
  .main-area { display: flex; flex: 1; min-height: 0; overflow: hidden; }

  /* LEFT PANEL */
  .left-panel { width: 280px; min-width: 280px; background: var(--bg-secondary); border-right: 1px solid var(--border); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; display: flex; flex-direction: column; }
  .panel-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .panel-section:last-child { border-bottom: none; }
  .section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 8px; }

  /* UPLOAD SLOTS — unified */
  .style-grid { display: flex; gap: 8px; margin-bottom: 8px; }
  .upload-slot {
    flex: 1; aspect-ratio: 1; background: var(--bg-primary); border: 2px dashed var(--border);
    border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden; position: relative;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  }
  .upload-slot:hover { border-color: var(--accent); background: rgba(124,92,252,0.04); box-shadow: 0 0 0 1px rgba(124,92,252,0.1); }
  .upload-slot:active { background: rgba(124,92,252,0.08); transform: scale(0.98); }
  .upload-slot.filled { border-style: solid; border-color: var(--border-light); }
  .upload-slot.filled:hover { border-color: var(--accent); }
  .upload-slot img { width: 100%; height: 100%; object-fit: cover; }
  .upload-slot .slot-label { font-size: 11px; color: var(--text-muted); text-align: center; pointer-events: none; letter-spacing: 0.3px; }
  .upload-slot .slot-remove {
    position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
    background: rgba(0,0,0,0.75); border: none; color: var(--text-primary); border-radius: 50%;
    font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center;
    transition: background 0.15s;
  }
  .upload-slot:hover .slot-remove { display: flex; }
  .upload-slot .slot-remove:hover { background: var(--red); }
  /* Backward compat aliases */
  .style-slot { flex: 1; aspect-ratio: 1; background: var(--bg-primary); border: 2px dashed var(--border); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; position: relative; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; }
  .style-slot:hover { border-color: var(--accent); background: rgba(124,92,252,0.04); box-shadow: 0 0 0 1px rgba(124,92,252,0.1); }
  .style-slot:active { background: rgba(124,92,252,0.08); transform: scale(0.98); }
  .style-slot.filled { border-style: solid; border-color: var(--border-light); }
  .style-slot img { width: 100%; height: 100%; object-fit: cover; }
  .style-slot .slot-label { font-size: 11px; color: var(--text-muted); text-align: center; pointer-events: none; }
  .style-slot .slot-remove { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(0,0,0,0.75); border: none; color: var(--text-primary); border-radius: 50%; font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center; }
  .style-slot:hover .slot-remove { display: flex; }
  .style-slot .slot-remove:hover { background: var(--red); }

  /* CHARACTER */
  .char-slot {
    width: 100%; aspect-ratio: 4/3; background: var(--bg-primary); border: 2px dashed var(--border);
    border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden; position: relative;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  }
  .char-slot:hover { border-color: var(--accent); background: rgba(124,92,252,0.04); box-shadow: 0 0 0 1px rgba(124,92,252,0.1); }
  .char-slot:active { background: rgba(124,92,252,0.08); transform: scale(0.98); }
  .char-slot.filled { border-style: solid; border-color: var(--border-light); }
  .char-slot img { height: 100%; object-fit: contain; }
  .char-slot .slot-label { font-size: 11px; color: var(--text-muted); pointer-events: none; }
  .char-slot .slot-remove {
    position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
    background: rgba(0,0,0,0.75); border: none; color: var(--text-primary); border-radius: 50%;
    font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center;
  }
  .char-slot:hover .slot-remove { display: flex; }
  .char-slot .slot-remove:hover { background: var(--red); }

  /* FORM */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-tertiary); color: var(--text-primary); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; white-space: nowrap; font-family: inherit;
  }
  .btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
  .btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .btn-accent { background: var(--accent); border-color: var(--accent); color: white; }
  .btn-accent:hover { background: var(--accent-hover); }
  .btn-accent:disabled { background: var(--bg-hover); border-color: var(--border); color: var(--text-muted); cursor: not-allowed; }
  .btn-green { background: var(--green); border-color: var(--green); color: white; }
  .btn-green:hover { opacity: 0.9; }
  .btn-orange { background: var(--orange); border-color: var(--orange); color: white; }
  .btn-orange:hover { opacity: 0.9; }
  .btn-sm { padding: 4px 8px; font-size: 11px; }
  .btn-icon { width: 32px; height: 32px; padding: 0; }
  .btn-row { display: flex; gap: 6px; }
  .btn-row .btn { flex: 1; }

  textarea {
    width: 100%; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary);
    border-radius: var(--radius); padding: 8px 10px; font-size: 11px; line-height: 1.4; resize: vertical;
    min-height: 60px; font-family: inherit; transition: border-color 0.15s;
  }
  textarea:focus { outline: none; border-color: var(--accent); }
  textarea::placeholder { color: var(--text-muted); }
  textarea.fixed-prompt { color: var(--text-muted); font-size: 10px; min-height: 50px; }

  select {
    width: 100%; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary);
    border-radius: var(--radius); padding: 6px 10px; font-size: 12px; font-family: inherit; cursor: pointer;
  }
  select:focus { outline: none; border-color: var(--accent); }

  input[type="range"] { width: 100%; height: 4px; -webkit-appearance: none; background: var(--border); border-radius: 2px; outline: none; }
  input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-secondary); }

  .field { display: flex; flex-direction: column; gap: 4px; }
  .field + .field { margin-top: 8px; }
  .field-label { font-size: 11px; color: var(--text-secondary); display: flex; justify-content: space-between; }
  .field-label strong { color: var(--text-primary); font-weight: 600; }

  /* ===== UNIFIED COLLAPSIBLE HEADER ===== */
  /* Universal chevron — open state points down, closed state points right (rotated -90°) */
  .hdr-chev {
    width: 10px; height: 10px; opacity: 0.7; flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.15s;
  }
  .hdr-chev.closed { transform: rotate(-90deg); }

  /* Base collapsible header — used by SETTINGS (muted variant) */
  .collapsible-header {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; user-select: none;
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted); margin-bottom: 14px;
    transition: color 0.15s;
  }
  .collapsible-header:hover { color: var(--text-secondary); }
  .collapsible-header:hover .hdr-chev { opacity: 1; }
  .collapsible-group.collapsed .collapsible-header { margin-bottom: 0; }
  .collapsible-group.collapsed .hdr-chev { transform: rotate(-90deg); }
  .collapsible-group.collapsed .collapsible-body { display: none; }

  /* SUB-SECTION (inside collapsible group) */
  .sub-section { margin-bottom: 16px; }
  .sub-section:last-child { margin-bottom: 0; }
  .sub-section-label {
    font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); margin-bottom: 8px; opacity: 0.75;
  }
  .sub-section-box {
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.015);
    border-radius: 10px;
    padding: 14px;
  }
  .sub-field-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); opacity: 0.75; margin-bottom: 6px;
  }
  .sub-field-label strong {
    font-size: 11px; letter-spacing: 0; text-transform: none;
    color: var(--text-primary); font-weight: 600; opacity: 1;
  }
  .sub-section-pill {
    display: flex; gap: 2px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.015);
    border-radius: 999px;
    padding: 4px;
  }
  .sub-section-pill .pill-btn {
    flex: 1; padding: 7px 10px; border: none; background: transparent;
    color: var(--text-muted); font-size: 12px; font-weight: 500;
    border-radius: 999px; cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .sub-section-pill .pill-btn:hover { color: var(--text-secondary); }
  .sub-section-pill .pill-btn.active {
    background: var(--bg-hover); color: var(--text-primary);
  }

  /* ASPECT RATIO GRID */
  .ar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .ar-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 6px 2px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-tertiary); color: var(--text-muted); cursor: pointer;
    font-size: 10px; transition: all 0.15s; min-height: 48px;
  }
  .ar-btn:hover { background: var(--bg-hover); color: var(--text-secondary); border-color: var(--border-light); }
  .ar-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
  .ar-btn svg { opacity: 0.7; }
  .ar-btn.active svg { opacity: 1; }

  input[type="file"] { display: none; }

  /* CANVAS AREA */
  .canvas-area {
    flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; background: #0a0a0f;
  }
  .canvas-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .canvas-top .label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); }
  .canvas-viewport { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
  .canvas-container { position: relative; display: inline-block; }
  .canvas-container canvas { position: absolute; top: 0; left: 0; }
  #imageCanvas { position: relative; }
  #maskCanvas { cursor: none; opacity: 0.45; }
  .canvas-viewport.panning #maskCanvas { cursor: grab; }

  .empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); font-size: 14px; cursor: pointer; z-index: 10; }
  .empty-state p { margin-top: 6px; font-size: 12px; }

  /* TOOLBAR */
  .toolbar {
    display: flex; align-items: center; gap: 4px; background: rgba(24,24,31,0.95);
    padding: 5px 8px; border-radius: var(--radius-lg); border: 1px solid var(--border);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
  .toolbar .brush-ctrl { display: flex; align-items: center; gap: 6px; }
  .toolbar .brush-ctrl span { font-size: 11px; color: var(--text-muted); white-space: nowrap; min-width: 28px; }
  .toolbar .brush-ctrl input[type="range"] { width: 80px; }
  .toolbar .zoom-info { font-size: 11px; color: var(--text-muted); min-width: 35px; text-align: center; }

  /* BRUSH CURSOR */
  .brush-cursor { position: fixed; pointer-events: none; border: 2px solid rgba(124,92,252,0.7); border-radius: 50%; z-index: 50; display: none; }
  .brush-cursor.visible { display: block; }

  /* PROGRESS */
  .progress-bar { display: none; padding: 8px; background: var(--accent-soft); border: 1px solid rgba(124,92,252,0.25); border-radius: var(--radius); text-align: center; }
  .progress-bar.active { display: block; }
  .progress-bar .spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 6px; vertical-align: middle; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .progress-bar .prog-text { font-size: 12px; color: var(--accent); }

  /* HISTORY inline inside active session card */
  .session-hist-wrap {
    display: none; flex-direction: column;
    border-top: 1px solid rgba(255,255,255,0.05); width: 100%;
    margin-top: 4px;
  }
  .sessions-panel.expanded .session-hist-wrap { display: flex; }
  .sessions-panel:not(.expanded) .session-hist-wrap { display: none !important; }
  .sh-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px 5px; flex-shrink: 0;
  }
  .sh-header span:first-child {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.8px; color: #14b8a6;
  }
  .sh-count {
    font-size: 9px; font-weight: 600; color: #14b8a6;
    background: rgba(20,184,166,0.12); padding: 1px 6px; border-radius: 999px;
  }
  .sh-body {
    overflow-y: auto; overflow-x: hidden; max-height: 55vh;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
    padding-bottom: 8px; width: 100%;
  }

  /* Step cards (tree-based history) */
  .h-step {
    margin: 0 6px 4px; border-radius: 10px; background: var(--bg-secondary);
    border: 1px solid transparent; overflow: hidden; transition: border-color 0.15s;
    min-width: 0; max-width: 100%;
  }
  .h-step:hover { border-color: rgba(255,255,255,0.06); }
  .h-step.current { border-color: rgba(124,92,252,0.3); }
  .h-step-hdr {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 10px 8px; cursor: pointer; user-select: none;
    overflow: hidden; min-width: 0;
  }
  .h-step-num {
    font-size: 10px; font-weight: 700; color: var(--accent);
    background: rgba(124,92,252,0.1); padding: 2px 7px; border-radius: 4px; white-space: nowrap;
    flex-shrink: 0;
  }
  .h-step-prompt {
    flex: 1; min-width: 0; font-size: 10px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .h-step-time { font-size: 9px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
  .h-step-chev {
    width: 10px; height: 10px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s;
  }
  .h-step.open .h-step-chev { transform: rotate(0deg); }
  .h-step:not(.open) .h-step-chev { transform: rotate(-90deg); }

  /* Visual section: BEFORE image + result thumbnails */
  .h-step-visual { display: none; flex-direction: column; gap: 8px; padding: 0 10px 10px; }
  .h-step.open .h-step-visual { display: flex; }
  .h-step-src {
    width: 100%; aspect-ratio: 16/10; border-radius: 8px;
    border: 1px solid rgba(245,158,11,0.35); overflow: hidden; position: relative;
  }
  .h-step-src img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .h-step-src-lbl {
    position: absolute; bottom: 5px; left: 6px;
    font-size: 9px; font-weight: 700; text-transform: uppercase;
    padding: 1px 6px; border-radius: 3px;
    background: rgba(0,0,0,0.55); color: rgba(245,158,11,0.8);
    letter-spacing: 0.3px;
  }
  .h-step-results { display: flex; gap: 5px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex-wrap: wrap; }
  .h-step-results::-webkit-scrollbar { display: none; }
  .h-step-res {
    width: 52px; height: 52px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden; flex-shrink: 0; cursor: pointer; position: relative;
    transition: border-color 0.15s;
  }
  .h-step-res:hover { border-color: rgba(124,92,252,0.5); }
  .h-step-res.active { border-color: var(--accent); box-shadow: 0 0 4px rgba(124,92,252,0.2); }
  .h-step-res.used { border-color: rgba(20,184,166,0.5); }
  .h-step-res img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .h-step-res-num {
    position: absolute; top: 2px; right: 2px; font-size: 8px; font-weight: 700; color: white;
    background: rgba(0,0,0,0.5); padding: 1px 4px; border-radius: 3px;
  }
  .h-step-res-used {
    position: absolute; bottom: 2px; left: 2px; font-size: 6px; font-weight: 700;
    color: #14b8a6; background: rgba(0,0,0,0.6); padding: 1px 3px; border-radius: 2px;
    text-transform: uppercase;
  }
  .h-step-res.failed {
    border-color: rgba(239,68,68,0.6); opacity: 0.7;
    background: repeating-linear-gradient(135deg, rgba(239,68,68,0.08), rgba(239,68,68,0.08) 4px, transparent 4px, transparent 8px);
  }
  .h-step-res.failed img { display: none; }
  .h-step-res-fail {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    font-size: 7px; color: #ef4444; text-align: center; padding: 2px;
  }
  .h-step-res-fail svg { width: 14px; height: 14px; opacity: 0.7; }
  .h-step-res-fail span { line-height: 1.1; word-break: break-word; }

  /* Generating indicator on step card */
  .h-step-gen-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 9px; font-weight: 600; color: #f59e0b;
    background: rgba(245,158,11,0.12); padding: 2px 7px; border-radius: 4px;
    margin-left: 6px; animation: gen-pulse 1.5s ease-in-out infinite;
  }
  @keyframes gen-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
  .h-step-gen-badge svg { width: 10px; height: 10px; animation: gen-spin 1s linear infinite; }
  @keyframes gen-spin { to { transform: rotate(360deg); } }

  /* Placeholder slots for pending results */
  .h-step-res.pending {
    border-color: rgba(245,158,11,0.3); border-style: dashed;
    background: rgba(245,158,11,0.05);
  }
  .h-step-res.pending img { display: none; }
  .h-step-res-pending {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  }
  .h-step-res-pending svg {
    width: 16px; height: 16px; color: rgba(245,158,11,0.5);
    animation: gen-spin 1.2s linear infinite;
  }

  /* Generating step border glow */
  .h-step.generating { border-color: rgba(245,158,11,0.4); box-shadow: 0 0 8px rgba(245,158,11,0.1); }
  .h-thumb-use {
    position: absolute; bottom: 3px; right: 3px; font-size: 7px; font-weight: 700;
    color: #fff; background: rgba(124,92,252,0.85); padding: 2px 5px; border-radius: 3px;
    cursor: pointer; opacity: 0; transition: opacity 0.15s; text-transform: uppercase;
    border: none; line-height: 1; z-index: 2;
  }
  .h-step-res:hover .h-thumb-use,
  .h-step-src:hover .h-thumb-use { opacity: 1; }
  .h-thumb-use:hover { background: rgba(124,92,252,1); }

  /* Details */
  .h-step-details { display: none; padding: 0 10px 10px; }
  .h-step.open .h-step-details { display: block; }
  .h-step-meta { display: flex; gap: 8px; padding-top: 4px; font-size: 9px; color: var(--text-muted); flex-wrap: wrap; }
  .h-step-meta strong { color: var(--text-secondary); font-weight: 600; }
  .h-step-actions { display: flex; gap: 5px; padding-top: 8px; flex-wrap: wrap; }
  .h-step-act {
    flex: 1; min-width: 0; padding: 5px 3px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.08);
    background: transparent; color: var(--text-muted); font-size: 8px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; text-transform: uppercase; letter-spacing: 0.3px;
    text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .h-step-act:hover { border-color: var(--border-light); color: var(--text-primary); }
  .h-step-act.use:hover { background: rgba(34,197,94,0.1); border-color: var(--green); color: var(--green); }
  .h-step-act.compare:hover { background: rgba(124,92,252,0.1); border-color: var(--accent); color: var(--accent); }
  .h-step-act.del:hover { background: rgba(239,68,68,0.1); border-color: var(--red); color: var(--red); }

  /* Chain connector between steps */
  .h-chain { display: flex; align-items: center; padding: 3px 16px; }
  .h-chain-line { width: 1px; height: 10px; background: rgba(255,255,255,0.06); margin-left: 20px; }

  /* RIGHT PANEL — Autoprompt (collapsible tabs) */
  .right-panel-wrap { display: flex; flex-shrink: 0; }

  /* ===== COLLAPSED: vertical tabs ===== */
  .rp-tabs {
    display: flex; flex-direction: column; padding: 12px 0 12px 0; gap: 8px;
    width: 42px; flex-shrink: 0; background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    align-items: flex-end;
    overflow: hidden; transition: width 0.2s, opacity 0.2s;
  }
  .right-panel-wrap.open .rp-tabs { width: 0; padding: 0; opacity: 0; pointer-events: none; border: none; }

  .rp-tabs .rp-tab-open {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 28px; cursor: pointer;
    color: var(--accent); font-size: 12px; opacity: 0.5;
    transition: opacity 0.2s; flex-shrink: 0; margin-bottom: 4px;
  }
  .rp-tabs .rp-tab-open:hover { opacity: 1; }

  .rp-tabs .rp-tab-item {
    display: flex; align-items: center; justify-content: center;
    writing-mode: vertical-rl; text-orientation: mixed; cursor: pointer;
    font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
    user-select: none; padding: 16px 6px; flex-shrink: 0;
    width: 32px;
    border-radius: 8px 0 0 8px;
    border-left: 3px solid transparent;
    transition: color 0.2s, background 0.2s, border-left-color 0.2s, transform 0.2s;
  }
  .rp-tabs .rp-tab-item:hover { transform: translateX(-4px); }

  /* Tab colors */
  .rp-tabs .rp-tab-item.tab-pink   { color: rgba(244,114,182,0.55); background: rgba(236,72,153,0.05); }
  .rp-tabs .rp-tab-item.tab-pink:hover   { color: #f472b6; background: rgba(236,72,153,0.15); border-left-color: #ec4899; }
  .rp-tabs .rp-tab-item.tab-blue   { color: rgba(96,165,250,0.55); background: rgba(59,130,246,0.05); }
  .rp-tabs .rp-tab-item.tab-blue:hover   { color: #60a5fa; background: rgba(59,130,246,0.15); border-left-color: #3b82f6; }
  .rp-tabs .rp-tab-item.tab-purple { color: rgba(167,139,250,0.55); background: rgba(139,92,246,0.05); }
  .rp-tabs .rp-tab-item.tab-purple:hover { color: #a78bfa; background: rgba(139,92,246,0.15); border-left-color: #8b5cf6; }
  .rp-tabs .rp-tab-item.tab-amber  { color: rgba(251,191,36,0.55); background: rgba(245,158,11,0.05); }
  .rp-tabs .rp-tab-item.tab-amber:hover  { color: #fbbf24; background: rgba(245,158,11,0.15); border-left-color: #f59e0b; }
  .rp-tabs .rp-tab-item.tab-emerald{ color: rgba(52,211,153,0.55); background: rgba(16,185,129,0.05); }
  .rp-tabs .rp-tab-item.tab-emerald:hover{ color: #34d399; background: rgba(16,185,129,0.15); border-left-color: #10b981; }

  /* ===== EXPANDED: panel ===== */
  .right-panel {
    width: 0; overflow: hidden; background: #111118; border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .right-panel-wrap.open .right-panel {
    width: 290px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  }

  /* Header */
  .right-panel .rp-header {
    display: flex; align-items: center; padding: 14px 14px 10px; gap: 8px; flex-shrink: 0;
  }
  .right-panel .rp-header-title {
    font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 1px;
    text-transform: uppercase;
    flex: 1; white-space: nowrap;
  }
  .right-panel .rp-header-close {
    width: 26px; height: 26px; border-radius: 6px; background: var(--accent-soft); border: none;
    color: var(--accent); font-size: 14px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: all 0.15s;
  }
  .right-panel .rp-header-close:hover { background: var(--accent); color: white; }

  /* ===== Sections — card tabs (same shape as collapsed tabs) ===== */
  .right-panel .rp-section {
    margin: 4px 0 4px 10px;
    border-radius: 8px 0 0 8px;
    border: none;
    border-left: 3px solid transparent;
    transition: transform 0.2s, border-left-color 0.2s;
  }
  .right-panel .rp-section:not(.open):hover { transform: translateX(-4px); }
  .right-panel .rp-section-header {
    display: flex; align-items: center; padding: 11px 14px; cursor: pointer;
    transition: background 0.2s; gap: 10px; min-height: 42px;
  }
  .right-panel .rp-section-title {
    font-size: 10px; font-weight: 600; margin-bottom: 0; letter-spacing: 0.8px; flex: 1;
    text-transform: uppercase;
    transition: color 0.2s;
  }
  .right-panel .rp-section-arrow {
    transition: transform 0.2s ease;
  }
  .right-panel .rp-section-arrow .hdr-chev { transform: rotate(-90deg); }
  .right-panel .rp-section.open .rp-section-arrow .hdr-chev { transform: rotate(0deg); }
  .right-panel .rp-section-body { display: none; }
  .right-panel .rp-section.open .rp-section-body { display: block; }
  .right-panel .rp-section-inner { padding: 2px 14px 14px; }
  .right-panel .rp-section-indicator {
    display: none;
  }

  /* ===== Section color themes (matches collapsed tab style) ===== */
  /* Pink */
  .rp-section.theme-pink { background: rgba(236,72,153,0.05); }
  .rp-section.theme-pink .rp-section-indicator { background: rgba(236,72,153,0.5); transition: background 0.2s; }
  .rp-section.theme-pink .rp-section-title { color: rgba(244,114,182,0.55); }
  .rp-section.theme-pink .rp-section-header:hover { background: rgba(236,72,153,0.15); }
  .rp-section.theme-pink .rp-section-header:hover .rp-section-title { color: #f472b6; }
  .rp-section.theme-pink .rp-section-header:hover .rp-section-indicator { background: #ec4899; }
  .rp-section.theme-pink:hover { border-left-color: #ec4899; }
  .rp-section.theme-pink.open { background: rgba(236,72,153,0.05); border-left-color: #ec4899; }
  .rp-section.theme-pink.open .rp-section-title { color: #f472b6; }
  .rp-section.theme-pink.open .rp-section-indicator { background: #ec4899; }

  /* Blue */
  .rp-section.theme-blue { background: rgba(59,130,246,0.05); }
  .rp-section.theme-blue .rp-section-indicator { background: rgba(59,130,246,0.5); transition: background 0.2s; }
  .rp-section.theme-blue .rp-section-title { color: rgba(96,165,250,0.55); }
  .rp-section.theme-blue .rp-section-header:hover { background: rgba(59,130,246,0.15); }
  .rp-section.theme-blue .rp-section-header:hover .rp-section-title { color: #60a5fa; }
  .rp-section.theme-blue .rp-section-header:hover .rp-section-indicator { background: #3b82f6; }
  .rp-section.theme-blue:hover { border-left-color: #3b82f6; }
  .rp-section.theme-blue.open { background: rgba(59,130,246,0.05); border-left-color: #3b82f6; }
  .rp-section.theme-blue.open .rp-section-title { color: #60a5fa; }
  .rp-section.theme-blue.open .rp-section-indicator { background: #3b82f6; }

  /* Purple */
  .rp-section.theme-purple { background: rgba(139,92,246,0.05); }
  .rp-section.theme-purple .rp-section-indicator { background: rgba(139,92,246,0.5); transition: background 0.2s; }
  .rp-section.theme-purple .rp-section-title { color: rgba(167,139,250,0.55); }
  .rp-section.theme-purple .rp-section-header:hover { background: rgba(139,92,246,0.15); }
  .rp-section.theme-purple .rp-section-header:hover .rp-section-title { color: #a78bfa; }
  .rp-section.theme-purple .rp-section-header:hover .rp-section-indicator { background: #8b5cf6; }
  .rp-section.theme-purple:hover { border-left-color: #8b5cf6; }
  .rp-section.theme-purple.open { background: rgba(139,92,246,0.05); border-left-color: #8b5cf6; }
  .rp-section.theme-purple.open .rp-section-title { color: #a78bfa; }
  .rp-section.theme-purple.open .rp-section-indicator { background: #8b5cf6; }

  /* Amber */
  .rp-section.theme-amber { background: rgba(245,158,11,0.05); }
  .rp-section.theme-amber .rp-section-indicator { background: rgba(245,158,11,0.5); transition: background 0.2s; }
  .rp-section.theme-amber .rp-section-title { color: rgba(251,191,36,0.55); }
  .rp-section.theme-amber .rp-section-header:hover { background: rgba(245,158,11,0.15); }
  .rp-section.theme-amber .rp-section-header:hover .rp-section-title { color: #fbbf24; }
  .rp-section.theme-amber .rp-section-header:hover .rp-section-indicator { background: #f59e0b; }
  .rp-section.theme-amber:hover { border-left-color: #f59e0b; }
  .rp-section.theme-amber.open { background: rgba(245,158,11,0.05); border-left-color: #f59e0b; }
  .rp-section.theme-amber.open .rp-section-title { color: #fbbf24; }
  .rp-section.theme-amber.open .rp-section-indicator { background: #f59e0b; }

  /* Emerald */
  .rp-section.theme-emerald { background: rgba(16,185,129,0.05); }
  .rp-section.theme-emerald .rp-section-indicator { background: rgba(16,185,129,0.5); transition: background 0.2s; }
  .rp-section.theme-emerald .rp-section-title { color: rgba(52,211,153,0.55); }
  .rp-section.theme-emerald .rp-section-header:hover { background: rgba(16,185,129,0.15); }
  .rp-section.theme-emerald .rp-section-header:hover .rp-section-title { color: #34d399; }
  .rp-section.theme-emerald .rp-section-header:hover .rp-section-indicator { background: #10b981; }
  .rp-section.theme-emerald:hover { border-left-color: #10b981; }
  .rp-section.theme-emerald.open { background: rgba(16,185,129,0.05); border-left-color: #10b981; }
  .rp-section.theme-emerald.open .rp-section-title { color: #34d399; }
  .rp-section.theme-emerald.open .rp-section-indicator { background: #10b981; }
  .right-panel .rp-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 6px; }
  .rp-style-grid { display: flex; gap: 8px; margin-bottom: 10px; }
  .rp-style-slot {
    flex: 1; aspect-ratio: 1; background: var(--bg-primary); border: 2px dashed var(--border);
    border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden; position: relative;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  }
  .rp-style-slot:hover { border-color: var(--accent); background: rgba(124,92,252,0.04); box-shadow: 0 0 0 1px rgba(124,92,252,0.1); }
  .rp-style-slot:active { background: rgba(124,92,252,0.08); transform: scale(0.98); }
  .rp-style-slot.filled { border-style: solid; border-color: var(--border-light); }
  .rp-style-slot.filled:hover { border-color: var(--accent); }
  .rp-style-slot img { width: 100%; height: 100%; object-fit: cover; }
  .rp-style-slot .slot-label { font-size: 11px; color: var(--text-muted); text-align: center; pointer-events: none; }
  .rp-style-slot .slot-remove {
    position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
    background: rgba(0,0,0,0.75); border: none; color: var(--text-primary); font-size: 12px;
    cursor: pointer; display: none; align-items: center; justify-content: center;
  }
  .rp-style-slot:hover .slot-remove { display: flex; }
  .rp-style-slot .slot-remove:hover { background: var(--red); }
  /* Prompt result — expandable */
  .rp-prompt-result {
    width: 100%; min-height: 60px; padding: 8px; font-size: 11px; line-height: 1.5;
    background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-secondary); resize: vertical; font-family: inherit;
    transition: border-color 0.2s;
    overflow-y: auto;
  }
  .rp-prompt-result:focus { border-color: var(--accent); outline: none; color: var(--text-primary); }
  .rp-prompt-result.expanded { min-height: 120px; }
  .rp-copy-btn {
    font-size: 10px; padding: 3px 10px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-muted); cursor: pointer; transition: all 0.15s; font-family: inherit;
  }
  .rp-copy-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

  /* INPAINT PRO — section */
  .pro-section { padding: 14px; }
  .pro-header {
    font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 1px;
    cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    user-select: none; text-transform: uppercase;
    transition: color 0.15s;
  }
  .pro-header:hover { color: var(--accent-hover); }
  .pro-header:hover .hdr-chev { opacity: 1; }
  .pro-header .hdr-chev { color: var(--accent); }
  .pro-content {
    max-height: 0; overflow: hidden; padding-top: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding-top 0.35s;
  }
  .pro-content.open { max-height: 1200px; padding-top: 14px; }
  .pro-checkbox {
    display: flex; align-items: center; gap: 8px; margin-top: 10px;
    font-size: 11px; color: var(--text-secondary); cursor: pointer;
  }
  .pro-checkbox input { accent-color: var(--accent); }

  /* VIEWER — redesigned */
  .viewer { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.97); z-index: 100; flex-direction: column; }
  .viewer.active { display: flex; }
  .viewer-top { display: flex; align-items: center; padding: 8px 20px; gap: 12px; flex-shrink: 0; }
  .viewer-top .viewer-counter { font-size: 12px; color: var(--text-muted); flex: 1; }
  .viewer-close { position: absolute; top: 8px; right: 16px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.7); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10; transition: all 0.15s; backdrop-filter: blur(8px); }
  .viewer-close:hover { background: rgba(255,255,255,0.15); color: white; }
  .viewer-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; padding: 8px 60px; }
  .viewer-img-container { position: relative; max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: grab; border-radius: var(--radius-lg); }
  .viewer-img-container.dragging { cursor: grabbing; }
  .viewer-img-container img { max-width: 100%; max-height: 88vh; object-fit: contain; border-radius: var(--radius-lg); display: block; user-select: none; transform-origin: center center; will-change: transform; }
  /* Before/After slider */
  .viewer-compare { position: relative; overflow: hidden; border-radius: var(--radius-lg); display: none; line-height: 0; box-shadow: 0 4px 40px rgba(0,0,0,0.6); }
  .viewer-compare > img { display: block; max-width: 100%; max-height: 88vh; user-select: none; pointer-events: none; }
  .viewer-compare .compare-clip { position: absolute; top: 0; left: 0; width: 50%; height: 100%; overflow: hidden; z-index: 2; }
  .viewer-compare .compare-clip img { display: block; height: 100%; user-select: none; pointer-events: none; }
  .viewer-compare .compare-divider {
    position: absolute; top: 0; width: 2px; height: 100%; background: white; cursor: ew-resize; z-index: 5;
    box-shadow: 0 0 12px rgba(0,0,0,0.6), 0 0 4px rgba(255,255,255,0.3); margin-left: -1px;
  }
  .viewer-compare .compare-divider::before {
    content: ''; position: absolute; top: 0; left: -15px; width: 33px; height: 100%; cursor: ew-resize;
  }
  .viewer-compare .compare-handle {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 36px; height: 36px; border-radius: 50%; background: white; border: none;
    display: flex; align-items: center; justify-content: center; font-size: 15px; color: #333;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 0 3px rgba(255,255,255,0.2); pointer-events: none;
  }
  .viewer-compare .compare-label {
    position: absolute; top: 12px; padding: 4px 14px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; z-index: 3; backdrop-filter: blur(8px);
  }
  .viewer-compare .compare-label.before { left: 12px; background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
  .viewer-compare .compare-label.after { right: 12px; background: rgba(124,92,252,0.2); color: #a78bfa; border: 1px solid rgba(124,92,252,0.3); }
  .viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); font-size: 22px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 5; transition: all 0.15s; backdrop-filter: blur(8px); }
  .viewer-nav:hover { background: rgba(255,255,255,0.12); color: white; }
  .viewer-nav.prev { left: 10px; }
  .viewer-nav.next { right: 10px; }
  /* Thumbnails strip */
  .viewer-thumbs { display: flex; gap: 6px; justify-content: center; padding: 6px 20px; flex-shrink: 0; }
  .viewer-thumb {
    width: 48px; height: 48px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.08); overflow: hidden; cursor: pointer; transition: all 0.15s; flex-shrink: 0; opacity: 0.6;
  }
  .viewer-thumb:hover { opacity: 0.9; border-color: rgba(255,255,255,0.2); }
  .viewer-thumb.active { border-color: var(--accent); box-shadow: 0 0 12px rgba(124,92,252,0.4); opacity: 1; }
  .viewer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  /* Action bar */
  .viewer-actions { display: flex; gap: 8px; justify-content: center; padding: 6px 20px 12px; flex-shrink: 0; }
  .viewer-action-btn {
    height: 36px; padding: 0 20px; border-radius: 20px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; transition: all 0.15s; font-family: inherit; gap: 6px; backdrop-filter: blur(8px);
  }
  .viewer-action-btn.inpaint { background: rgba(124,92,252,0.2); color: #a78bfa; border: 1px solid rgba(124,92,252,0.3); }
  .viewer-action-btn.inpaint:hover { background: var(--accent); color: white; border-color: var(--accent); }
  .viewer-action-btn.download { background: rgba(255,255,255,0.06); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.1); }
  .viewer-action-btn.download:hover { background: rgba(255,255,255,0.12); color: white; }
  .viewer-action-btn.delete { background: rgba(239,68,68,0.1); color: rgba(239,68,68,0.7); border: 1px solid rgba(239,68,68,0.15); }
  .viewer-action-btn.delete:hover { background: var(--red); color: white; border-color: var(--red); }
  /* Viewer info */
  .viewer-info { display: none; text-align: center; padding: 0 20px 4px; font-size: 10px; color: var(--text-muted); }
  .viewer-info.visible { display: block; }

  /* ZOOM FLOAT */
  .zoom-float { position: absolute; right: 16px; top: 16px; z-index: 20; display: none; flex-direction: column; gap: 4px; align-items: center; }
  .zoom-float.visible { display: flex; }
  .zoom-float-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-secondary); color: white; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: opacity 0.2s, background 0.2s; }
  .zoom-float-btn:hover { opacity: 1; background: var(--accent); border-color: var(--accent); }
  .zoom-float-info { font-size: 10px; color: var(--text-muted); }

  /* TOAST */
  .toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
  .toast { padding: 10px 16px; border-radius: var(--radius); font-size: 12px; font-weight: 500; animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
  .toast.info { background: var(--accent); color: white; }
  .toast.success { background: var(--green); color: white; }
  .toast.error { background: var(--red); color: white; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
  @keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
