/* ═══════════════════════════════════════════════════════════
   SBER CREATOR — styles.css v16
   Themes: dark | light | midnight | sber
   ═══════════════════════════════════════════════════════════ */

/* ── THEME: dark (default) ─────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg-primary:    #0a0a0a;
  --bg-secondary:  #111111;
  --bg-tertiary:   #1a1a1a;
  --bg-elevated:   #222222;
  --bg-card:       #1a1a1a;
  --border:        rgba(255,255,255,0.08);
  --border-hover:  rgba(255,255,255,0.18);
  --text-primary:  #f0f0f0;
  --text-secondary:#a0a0a0;
  --text-muted:    #606060;
  --accent-primary:#22c55e;
  --accent-hover:  #16a34a;
  --accent-glow:   rgba(34,197,94,0.25);
  --accent-soft:   rgba(34,197,94,0.12);
  --sidebar-bg:    #0d0d0d;
  --panel-bg:      #111111;
  --shadow:        0 4px 24px rgba(0,0,0,0.6);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --font:          'Outfit', -apple-system, sans-serif;
  --ball-opacity:  0.18;
}

/* ── THEME: light ──────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:    #f8f9fa;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #f0f0f0;
  --bg-elevated:   #e8e8e8;
  --bg-card:       #ffffff;
  --border:        rgba(0,0,0,0.10);
  --border-hover:  rgba(0,0,0,0.22);
  --text-primary:  #111111;
  --text-secondary:#555555;
  --text-muted:    #999999;
  --accent-primary:#16a34a;
  --accent-hover:  #15803d;
  --accent-glow:   rgba(22,163,74,0.20);
  --accent-soft:   rgba(22,163,74,0.10);
  --sidebar-bg:    #ffffff;
  --panel-bg:      #f8f9fa;
  --shadow:        0 4px 24px rgba(0,0,0,0.12);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.08);
  --ball-opacity:  0.10;
}

/* ── THEME: sber ───────────────────────────────────────── */
[data-theme="sber"] {
  --bg-primary:    #f0f5f1;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #e8f0ea;
  --bg-elevated:   #dceede;
  --bg-card:       #ffffff;
  --border:        rgba(33,160,56,0.15);
  --border-hover:  rgba(33,160,56,0.35);
  --text-primary:  #1d1d1b;
  --text-secondary:#4a5c4c;
  --text-muted:    #8aaa8c;
  --accent-primary:#21a038;
  --accent-hover:  #1a8030;
  --accent-glow:   rgba(33,160,56,0.25);
  --accent-soft:   rgba(33,160,56,0.10);
  --sidebar-bg:    #ffffff;
  --panel-bg:      #f0f5f1;
  --shadow:        0 4px 24px rgba(33,160,56,0.12);
  --shadow-sm:     0 2px 8px rgba(33,160,56,0.08);
  --ball-opacity:  0.10;
}

/* ── THEME: midnight ───────────────────────────────────── */
[data-theme="midnight"] {
  --bg-primary:    #0e0a1a;
  --bg-secondary:  #130e22;
  --bg-tertiary:   #1c1530;
  --bg-elevated:   #251d3c;
  --bg-card:       #1c1530;
  --border:        rgba(127,90,240,0.15);
  --border-hover:  rgba(127,90,240,0.35);
  --text-primary:  #ede9ff;
  --text-secondary:#9b88d4;
  --text-muted:    #5c4e8a;
  --accent-primary:#7f5af0;
  --accent-hover:  #6b44e0;
  --accent-glow:   rgba(127,90,240,0.30);
  --accent-soft:   rgba(127,90,240,0.12);
  --sidebar-bg:    #0e0a1a;
  --panel-bg:      #130e22;
  --shadow:        0 4px 24px rgba(0,0,0,0.7);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.5);
  --ball-opacity:  0.16;
}

/* ════════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════════ */

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ── Animated background canvas ─────────────────────────── */
#backgroundCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════ */

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
  overflow: hidden;
  transition: background 0.3s;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 36px;
  height: 36px;
}

.logo span {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-footer {
  margin-top: auto;
}

/* ── THEME SWITCHER ──────────────────────────────────────── */
.theme-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
}

.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.theme-btn.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace {
  display: flex;
  height: 100%;
  gap: 0;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════
   PANELS
   ════════════════════════════════════════════════════════ */

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.3s;
}

/* ── LEFT PANEL: Settings ────────────────────────────────── */
.panel-settings {
  width: 340px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-settings::-webkit-scrollbar {
  width: 4px;
}
.panel-settings::-webkit-scrollbar-track { background: transparent; }
.panel-settings::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── RIGHT PANEL: Gallery ────────────────────────────────── */
.panel-gallery {
  flex: 1;
  background: var(--bg-primary);
  padding: 16px;
  gap: 12px;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea,
select,
input[type="text"],
input[type="range"] {
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  max-height: 160px;
  line-height: 1.5;
}

textarea:focus,
select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
  color: var(--text-muted);
}

/* ── Aspect Ratio Select ─────────────────────────────────── */
.aspect-ratio-select {
  width: 100%;
  padding: 9px 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

/* ════════════════════════════════════════════════════════
   UPLOAD ZONE
   ════════════════════════════════════════════════════════ */

.upload-zone.compact {
  height: 72px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.upload-zone.compact:hover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.upload-zone.compact.drag-over {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.upload-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  pointer-events: none;
}

.upload-placeholder svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.upload-preview {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-preview img {
  max-height: 68px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.remove-upload {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(220, 50, 50, 0.85);
  color: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-upload:hover {
  background: rgba(220, 50, 50, 1);
}

/* ════════════════════════════════════════════════════════
   CHARACTER PILLS
   ════════════════════════════════════════════════════════ */

.char-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.char-pill {
  cursor: pointer;
}

.char-pill input[type="radio"] {
  display: none;
}

.char-pill-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px 7px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  transition: all 0.18s;
  user-select: none;
}

.char-pill:hover .char-pill-inner {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.char-pill input:checked + .char-pill-inner {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.char-pill-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  background: var(--bg-elevated);
}

.char-pill-icon svg {
  width: 20px;
  height: 20px;
}

.char-pill input:checked + .char-pill-inner .char-pill-icon {
  color: var(--accent-primary);
}

.char-pill-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.char-pill-name {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.char-pill input:checked + .char-pill-inner .char-pill-name {
  color: var(--accent-primary);
}

/* ════════════════════════════════════════════════════════
   EMOTION GRID
   ════════════════════════════════════════════════════════ */

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.emotion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px 5px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.emotion-btn:hover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.emotion-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.emotion-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.emotion-icon svg {
  width: 22px;
  height: 22px;
}

.emotion-label {
  font-size: 0.54rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  border: none;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-glow);
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════ */

/* ── Secondary Button ────────────────────────────────────── */
.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

/* ── Cancel Button ───────────────────────────────────────── */
.btn-cancel {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-cancel:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.16);
}

/* ── Magic Generate Button ───────────────────────────────── */
.btn-generate-magic {
  --black-700: var(--bg-elevated);
  align-items: center;
  appearance: none;
  background-image: radial-gradient(100% 100% at 100% 0, var(--accent-primary) 0, var(--accent-hover) 100%);
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: rgba(45, 35, 66, .4) 0 2px 4px, rgba(45, 35, 66, .3) 0 7px 13px -3px, var(--black-700) 0 -3px 0 inset;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  height: 44px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  overflow: hidden;
  padding: 0 18px;
  position: relative;
  text-align: left;
  transition: box-shadow .15s, transform .15s;
  user-select: none;
  touch-action: manipulation;
  will-change: box-shadow, transform;
  width: 100%;
  gap: 8px;
}

[data-theme="sber"] .btn-generate-magic {
  --black-700: #1a3a22;
}

[data-theme="midnight"] .btn-generate-magic {
  background-image: radial-gradient(100% 100% at 100% 0, #7f5af0 0, #6b44e0 100%);
  --black-700: #1a0f3a;
}

[data-theme="light"] .btn-generate-magic {
  --black-700: #d4f0db;
}

.btn-generate-magic:focus {
  box-shadow: var(--black-700) 0 0 0 1.5px inset, rgba(45, 35, 66, .4) 0 2px 4px, rgba(45, 35, 66, .3) 0 7px 13px -3px, var(--black-700) 0 -3px 0 inset;
}

.btn-generate-magic:hover {
  box-shadow: rgba(45, 35, 66, .4) 0 4px 8px, rgba(45, 35, 66, .3) 0 7px 13px -3px, var(--black-700) 0 -3px 0 inset;
  transform: translateY(-2px);
}

.btn-generate-magic:active {
  box-shadow: var(--black-700) 0 3px 7px inset;
  transform: translateY(2px);
}

.btn-generate-magic.loading {
  pointer-events: none;
  opacity: 0.75;
}

/* Dots border spinner */
.dots_border {
  --size_dots: 7px;
  --color_dots: rgba(255,255,255,0.6);
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  display: none;
}

.btn-generate-magic.loading .dots_border {
  display: block;
}

.dots_border::before,
.dots_border::after {
  content: "";
  display: block;
  height: var(--size_dots);
  width: var(--size_dots);
  background: var(--color_dots);
  border-radius: 50%;
  position: absolute;
  animation: spin_dots 1.5s linear infinite;
}

.dots_border::before {
  left: 0; top: 50%;
  transform: translateY(-50%);
  animation-delay: 0s;
}

.dots_border::after {
  right: 0; top: 50%;
  transform: translateY(-50%);
  animation-delay: 0.75s;
}

@keyframes spin_dots {
  0%   { transform: translateY(-50%) scale(1); opacity: 1; }
  50%  { transform: translateY(-50%) scale(0.4); opacity: 0.3; }
  100% { transform: translateY(-50%) scale(1); opacity: 1; }
}

/* Sparkle */
.sparkle {
  fill: rgba(255,255,255,0.8);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-generate-magic.loading .sparkle {
  animation: sparkle_rotate 1s linear infinite;
}

@keyframes sparkle_rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.text_button {
  position: relative;
  z-index: 1;
}

/* ════════════════════════════════════════════════════════
   GALLERY
   ════════════════════════════════════════════════════════ */

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.gallery-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.gallery-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 220px;
  padding: 2px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.image-gallery::-webkit-scrollbar { width: 4px; }
.image-gallery::-webkit-scrollbar-track { background: transparent; }
.image-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.gallery-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.18s;
  background: var(--bg-tertiary);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumb:hover {
  border-color: var(--accent-primary);
  transform: scale(1.02);
  box-shadow: var(--shadow-sm);
}

.gallery-thumb.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.gallery-thumb.loading-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
}

.gallery-thumb-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.gallery-thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  line-height: 1;
}

.gallery-thumb:hover .gallery-thumb-delete {
  display: flex;
}

.gallery-thumb-delete:hover {
  background: rgba(220, 50, 50, 0.9);
}

/* ── Selected image preview ──────────────────────────────── */
.selected-image-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

.selected-image-preview.hidden {
  display: none;
}

.preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.preview-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}

.preview-action-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.preview-action-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.preview-action-edit {
  border-color: rgba(168, 85, 247, 0.3);
  color: #a855f7;
}

.preview-action-edit:hover {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.1);
  color: #a855f7;
}

#generatedImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: block;
  min-height: 0;
  flex: 1;
}

/* ════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  line-height: 1;
}

.modal-close:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ── Fullscreen Modal ────────────────────────────────────── */
#fullscreenModal .modal-overlay {
  background: rgba(0,0,0,0.92);
}

.fullscreen-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95vw;
  max-height: 95vh;
}

.fullscreen-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
  line-height: 1;
}

.fullscreen-close:hover {
  border-color: #ef4444;
  background: rgba(220, 50, 50, 0.4);
}

#fullscreenImage {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* ── Inpaint Modal ───────────────────────────────────────── */
.inpaint-modal-content {
  width: 92vw;
  max-width: 1100px;
  height: 88vh;
}

.inpaint-body {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.inpaint-canvas-wrap {
  flex: 0 0 62%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.inpaint-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

#inpaintCanvas {
  cursor: crosshair;
  display: block;
  background: var(--bg-tertiary);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
}

.inpaint-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.inpaint-tool {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}

.inpaint-tool:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.inpaint-tool.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.brush-size-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 120px;
}

.brush-size-wrap span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.brush-size-wrap input[type="range"] {
  flex: 1;
}

#brushSizeValue {
  min-width: 24px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.inpaint-clear {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.inpaint-clear:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.16);
}

.inpaint-sidebar {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}

.inpaint-sidebar label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.inpaint-sidebar textarea {
  min-height: 100px;
  resize: vertical;
}

.inpaint-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════════
   UTILITY
   ════════════════════════════════════════════════════════ */

.hidden {
  display: none !important;
}

/* ── Loading skeleton ────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.8; }
}

.skeleton {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ── Notification toast ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.25s ease;
}

.toast.toast-success { border-color: var(--accent-primary); }
.toast.toast-error   { border-color: #ef4444; color: #ef4444; }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ════════════════════════════════════════════════════════
   SCROLLBAR (global)
   ════════════════════════════════════════════════════════ */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
