/* ═══════════════════════════════════════════════════
   WAN 2.7 IMAGE STUDIO — STYLESHEET
   Aesthetic: Dark glassmorphism, Syne + DM Sans
   Author: Senior UI Engineer
════════════════════════════════════════════════════ */

/* ── FONT IMPORTS (fallback if Google Fonts loads) ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ═══════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES
════════════════════════════════════════════════════ */
:root {
  /* Core Palette */
  --bg-base:        #080b10;
  --bg-surface:     #0d1117;
  --bg-elevated:    #131920;

  /* Glass */
  --glass-bg:       rgba(16, 22, 32, 0.72);
  --glass-border:   rgba(255, 255, 255, 0.075);
  --glass-shine:    rgba(255, 255, 255, 0.04);
  --glass-blur:     18px;
  --glass-shadow:   0 8px 40px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);

  /* Brand Accent */
  --accent-primary:    #7c6af5;
  --accent-secondary:  #a78bfa;
  --accent-glow:       rgba(124, 106, 245, 0.3);
  --accent-btn-from:   #6d58ef;
  --accent-btn-to:     #9b78f0;

  /* Status Colors */
  --color-success:  #34d399;
  --color-warning:  #fbbf24;
  --color-error:    #f87171;
  --color-info:     #60a5fa;

  /* Text */
  --text-primary:   #eef0f6;
  --text-secondary: #8b92a8;
  --text-muted:     #4d5568;
  --text-accent:    #a78bfa;

  /* Borders */
  --border-subtle:  rgba(255,255,255,0.055);
  --border-active:  rgba(124, 106, 245, 0.55);

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --radius-full: 999px;

  /* Transitions */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:  0.15s;
  --t-base:  0.25s;
  --t-slow:  0.4s;

  /* Typography */
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  /* Layout */
  --app-max-width: 1160px;
  --header-height: 64px;
  --panel-padding: 24px;
}

/* ═══════════════════════════════════════════════════
   RESET & BASE
════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100svh;
  overflow-x: hidden;
  line-height: 1.6;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════
   AMBIENT BACKGROUND ORBS
════════════════════════════════════════════════════ */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  animation: orb-drift 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #7c6af5, transparent 70%);
  top: -140px;
  left: -100px;
  animation-duration: 20s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #3b82f6, transparent 70%);
  top: 40%;
  right: -80px;
  animation-duration: 14s;
  animation-delay: -6s;
  opacity: 0.12;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #a855f7, transparent 70%);
  bottom: 10%;
  left: 30%;
  animation-duration: 17s;
  animation-delay: -10s;
  opacity: 0.10;
}

@keyframes orb-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, 20px) scale(1.08); }
  100% { transform: translate(-15px, 35px) scale(0.95); }
}

/* ═══════════════════════════════════════════════════
   GLASSMORPHISM PANEL
════════════════════════════════════════════════════ */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--glass-shine) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════
   APP SHELL & LAYOUT
════════════════════════════════════════════════════ */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-md);
  padding-bottom: var(--space-xl);
}

/* ── HEADER ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  margin: var(--space-md) 0 var(--space-lg);
  border-radius: var(--radius-xl);
  padding: 12px var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-btn-from), var(--accent-btn-to));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 5px 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transition: background var(--t-base) var(--ease-out);
  flex-shrink: 0;
}

.status-dot.idle       { background: var(--text-muted); }
.status-dot.processing { background: var(--color-warning); animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.success    { background: var(--color-success); }
.status-dot.error      { background: var(--color-error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

.status-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--t-base);
}

/* ── MAIN GRID ── */
.app-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  flex: 1;
}

@media (min-width: 900px) {
  .app-main {
    grid-template-columns: 340px 1fr;
    align-items: start;
  }
}

/* ═══════════════════════════════════════════════════
   CONFIG PANEL (LEFT)
════════════════════════════════════════════════════ */
.config-panel {
  border-radius: var(--radius-xl);
  padding: var(--panel-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

@media (min-width: 900px) {
  .config-panel {
    position: sticky;
    top: calc(var(--header-height) + var(--space-lg) * 2);
    max-height: calc(100svh - var(--header-height) - var(--space-xl) * 2);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
  }
  .config-panel::-webkit-scrollbar { width: 4px; }
  .config-panel::-webkit-scrollbar-track { background: transparent; }
  .config-panel::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
}

/* ── Panel Sections ── */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: relative;
  z-index: 1;
}

.panel-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-subtle), transparent);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-label svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ── Fields ── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.field-value-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent-secondary);
  background: rgba(124, 106, 245, 0.15);
  border: 1px solid rgba(124, 106, 245, 0.25);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  line-height: 1.6;
}

.field-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Input Wrapper ── */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.field-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 40px 10px 14px;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), background var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}

.field-input:focus {
  border-color: var(--accent-primary);
  background: rgba(124, 106, 245, 0.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-input::placeholder { color: var(--text-muted); }

/* Remove number input spinners */
.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.field-input[type="number"] { -moz-appearance: textfield; }

.input-icon-btn {
  position: absolute;
  right: 4px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--t-fast), background var(--t-fast);
}

.input-icon-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

.input-icon-btn svg { width: 15px; height: 15px; }

/* ── Segmented Control (Model Selector) ── */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.segment {
  border-radius: 9px;
  padding: 8px var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: all var(--t-base) var(--ease-out);
  position: relative;
}

.segment.active {
  background: linear-gradient(135deg, rgba(124,106,245,0.25), rgba(167,139,250,0.15));
  border: 1px solid rgba(124,106,245,0.35);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(124,106,245,0.2);
}

.segment:hover:not(.active) { background: rgba(255,255,255,0.04); color: var(--text-primary); }

.segment-name { font-family: var(--font-display); font-weight: 600; }

.segment-badge {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  padding: 1px 6px;
}

.segment.active .segment-badge { color: var(--text-secondary); background: rgba(124,106,245,0.2); }

.segment-badge.pro {
  background: linear-gradient(90deg, rgba(124,106,245,0.4), rgba(168,85,247,0.4));
  color: var(--accent-secondary);
}

/* ── Chip Group (Resolution) ── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font-display);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--t-base) var(--ease-out);
}

.chip.active {
  background: rgba(124,106,245,0.2);
  border-color: rgba(124,106,245,0.5);
  color: var(--accent-secondary);
  box-shadow: 0 0 10px rgba(124,106,245,0.2);
}

.chip:hover:not(.active) { background: rgba(255,255,255,0.07); border-color: var(--border-subtle); color: var(--text-primary); }

.chip.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ── Range Slider ── */
.slider-track-wrap { display: flex; flex-direction: column; gap: 6px; }

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent-primary) 0%,
    var(--accent-primary) var(--slider-pct, 0%),
    rgba(255,255,255,0.1) var(--slider-pct, 0%)
  );
  outline: none;
  cursor: pointer;
  transition: background var(--t-fast);
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-btn-from), var(--accent-btn-to));
  box-shadow: 0 0 0 3px rgba(124,106,245,0.3), 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-fast);
}

.range-slider::-webkit-slider-thumb:hover { transform: scale(1.15); box-shadow: 0 0 0 5px rgba(124,106,245,0.25), 0 2px 8px rgba(0,0,0,0.4); }
.range-slider:active::-webkit-slider-thumb { transform: scale(1.2); }

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-btn-from), var(--accent-btn-to));
  box-shadow: 0 0 0 3px rgba(124,106,245,0.3);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
}

.slider-ticks span {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-display);
}

/* ── Toggle Switch ── */
.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle-info { display: flex; flex-direction: column; gap: 2px; }
.toggle-info .field-label { font-size: 0.82rem; }

.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  display: flex;
  align-items: center;
  width: 52px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  transition: all var(--t-base) var(--ease-out);
  position: relative;
}

.toggle-switch input:checked + .toggle-track {
  background: linear-gradient(135deg, rgba(124,106,245,0.35), rgba(167,139,250,0.25));
  border-color: rgba(124,106,245,0.5);
  box-shadow: 0 0 10px rgba(124,106,245,0.25);
}

.toggle-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-base) var(--ease-spring), background var(--t-base);
  position: relative;
}

.toggle-switch input:checked + .toggle-track .toggle-knob {
  transform: translateX(24px);
  background: linear-gradient(135deg, var(--accent-btn-from), var(--accent-btn-to));
  box-shadow: 0 2px 8px rgba(124,106,245,0.5);
}

.knob-icon-on, .knob-icon-off {
  position: absolute;
  width: 11px;
  height: 11px;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.knob-icon-on  { opacity: 0; color: white; }
.knob-icon-off { opacity: 1; color: var(--text-muted); }

.toggle-switch input:checked + .toggle-track .knob-icon-on  { opacity: 1; }
.toggle-switch input:checked + .toggle-track .knob-icon-off { opacity: 0; }

/* ── Palette Engine ── */
/* ═══════════════════════════════════════════════════
   COLOR PALETTE REDESIGN (128-COLOR PICKER)
════════════════════════════════════════════════════ */

/* No Preset Button */
.no-preset-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-base);
}

.no-preset-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(124,106,245,0.3);
}

.no-preset-btn.active {
  background: rgba(124,106,245,0.15);
  border-color: rgba(124,106,245,0.5);
  color: var(--accent-secondary);
}

/* 128-Color Grid */
.color-palette-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  background: rgba(0,0,0,0.2);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
  border-color: rgba(255,255,255,0.4);
  box-shadow: 0 0 8px rgba(0,0,0,0.6);
}

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 6px rgba(124,106,245,0.8), inset 0 0 4px rgba(255,255,255,0.3);
}

.color-swatch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Selected Colors List */
.selected-colors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 40px;
}

.selected-color-item {
  display: grid;
  grid-template-columns: 32px 1fr 80px auto;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,0.03);
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.05);
}

.selected-color-preview {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all var(--t-fast);
}

.selected-color-preview:hover {
  border-color: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

.selected-color-hex {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  user-select: all;
}

.selected-color-ratio-input {
  padding: 4px 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.75rem;
  width: 70px;
  text-align: right;
}

.selected-color-ratio-input:focus {
  outline: none;
  border-color: rgba(124,106,245,0.5);
  background: rgba(124,106,245,0.1);
}

.selected-color-remove {
  background: rgba(244,63,94,0.1);
  border: 1px solid rgba(244,63,94,0.3);
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  color: rgba(244,63,94,0.8);
  transition: all var(--t-fast);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selected-color-remove:hover {
  background: rgba(244,63,94,0.2);
  border-color: rgba(244,63,94,0.6);
  color: #f43f5e;
}

/* ═══════════════════════════════════════════════════
   GENERATE PANEL (RIGHT)
════════════════════════════════════════════════════ */
.generate-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ── Prompt Card ── */
.prompt-card {
  border-radius: var(--radius-xl);
  padding: var(--panel-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.char-counter {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 500;
  transition: color var(--t-fast);
}

.char-counter.warning { color: var(--color-warning); }
.char-counter.danger  { color: var(--color-error); }

.prompt-textarea {
  width: 100%;
  min-height: 130px;
  max-height: 280px;
  resize: vertical;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 300;
  line-height: 1.65;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.prompt-textarea:focus {
  border-color: var(--accent-primary);
  background: rgba(124,106,245,0.04);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.prompt-textarea::placeholder { color: var(--text-muted); font-style: italic; font-weight: 300; }

/* ── Generate Button ── */
.generate-btn {
  position: relative;
  width: 100%;
  padding: 14px var(--space-lg);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-btn-from) 0%, var(--accent-btn-to) 100%);
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-base), opacity var(--t-fast);
  box-shadow: 0 4px 20px rgba(124,106,245,0.4), 0 1px 3px rgba(0,0,0,0.3);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,106,245,0.5), 0 2px 6px rgba(0,0,0,0.3);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 3px 14px rgba(124,106,245,0.35);
}

.generate-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity var(--t-fast);
}

.btn-content svg { width: 18px; height: 18px; }

.btn-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: shimmer 2.8s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.generate-btn.loading .btn-shimmer { animation: shimmer-fast 1s linear infinite; }

@keyframes shimmer-fast {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Processing Card ── */
.processing-card {
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--panel-padding);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  text-align: center;
}

.thinking-animation {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.think-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: spin-ring 2s linear infinite;
}

.ring-1 {
  width: 80px; height: 80px;
  border-top-color: var(--accent-primary);
  border-right-color: rgba(124,106,245,0.3);
  animation-duration: 2s;
}

.ring-2 {
  width: 60px; height: 60px;
  border-bottom-color: var(--accent-secondary);
  border-left-color: rgba(167,139,250,0.3);
  animation-duration: 1.6s;
  animation-direction: reverse;
}

.ring-3 {
  width: 42px; height: 42px;
  border-top-color: rgba(168,85,247,0.7);
  border-right-color: rgba(168,85,247,0.2);
  animation-duration: 1.2s;
}

@keyframes spin-ring {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.think-core {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-btn-from), var(--accent-btn-to));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--accent-glow);
  animation: core-pulse 1.8s ease-in-out infinite;
  z-index: 1;
}

.think-core svg { width: 12px; height: 12px; color: white; }

@keyframes core-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px var(--accent-glow); }
  50%       { transform: scale(1.12); box-shadow: 0 0 22px rgba(124,106,245,0.55); }
}

.processing-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.processing-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.processing-progress {
  width: 100%;
  max-width: 240px;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-btn-from), var(--accent-btn-to));
  animation: progress-indeterminate 2s ease-in-out infinite;
  transform-origin: left;
}

@keyframes progress-indeterminate {
  0%   { width: 0%; margin-left: 0%; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ── Gallery ── */
.results-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: fade-up var(--t-slow) var(--ease-out) both;
}

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

.gallery-header {
  border-radius: var(--radius-lg);
  padding: 12px var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.gallery-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-display);
}

/* ── Carousel ── */
.carousel-outer {
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  position: relative;
}

.carousel-track-wrap {
  overflow: hidden;
  border-radius: var(--radius-lg);
  position: relative;
}

.carousel-track {
  display: flex;
  transition: transform 0.42s var(--ease-out);
  will-change: transform;
  user-select: none;
}

.carousel-slide {
  flex: 0 0 100%;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  aspect-ratio: 16/10;
  min-height: 260px;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease-out);
  display: block;
}

.carousel-slide:hover img { transform: scale(1.025); }

/* Slide Actions Overlay */
.slide-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
}

.carousel-slide:hover .slide-actions,
.carousel-slide:focus-within .slide-actions {
  opacity: 1;
  transform: translateY(0);
}

.slide-index-badge {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.4);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  backdrop-filter: blur(6px);
}

.slide-action-btns { display: flex; gap: 6px; }

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-display);
  background: rgba(10,10,16,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  color: white;
  backdrop-filter: blur(8px);
  transition: all var(--t-fast) var(--ease-out);
}

.action-btn svg { width: 13px; height: 13px; }

.action-btn:hover {
  background: rgba(124,106,245,0.3);
  border-color: rgba(124,106,245,0.5);
  transform: translateY(-2px);
}

.action-btn:active { transform: translateY(0) scale(0.96); }

/* Carousel Navigation Arrows */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10,10,16,0.75);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  transition: all var(--t-fast) var(--ease-out);
  z-index: 10;
}

.carousel-nav:hover {
  background: rgba(124,106,245,0.3);
  border-color: rgba(124,106,245,0.4);
  transform: translateY(-50%) scale(1.08);
}

.carousel-nav.prev { left: -10px; }
.carousel-nav.next { right: -10px; }
.carousel-nav svg { width: 18px; height: 18px; }

/* Carousel Dots */
.carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: var(--space-md);
}

.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-base) var(--ease-out);
  border: none;
}

.carousel-dot.active {
  width: 22px;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
  z-index: 9999;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: rgba(14, 18, 26, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toast-in var(--t-base) var(--ease-spring) both;
  min-width: 260px;
}

.toast.toast-out {
  animation: toast-out var(--t-base) var(--ease-out) both;
}

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

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

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-body { flex: 1; }

.toast-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.4;
}

.toast.success .toast-icon { color: var(--color-success); }
.toast.error   .toast-icon { color: var(--color-error); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.info    .toast-icon { color: var(--color-info); }

.toast.success { border-color: rgba(52,211,153,0.2); }
.toast.error   { border-color: rgba(248,113,113,0.2); }
.toast.warning { border-color: rgba(251,191,36,0.2); }
.toast.info    { border-color: rgba(96,165,250,0.2); }

/* ═══════════════════════════════════════════════════
   UTILITY STATES
════════════════════════════════════════════════════ */
[hidden] { display: none !important; }

.fade-in {
  animation: fade-up var(--t-slow) var(--ease-out) both;
}

/* Skeleton loading for images */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 899px) {
  :root {
    --panel-padding: 18px;
  }

  .app-shell {
    padding: 0 12px 28px;
  }

  .app-header {
    margin: 10px 0 14px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
  }

  .brand-title { font-size: 0.95rem; }

  .carousel-nav {
    width: 32px;
    height: 32px;
  }
  .carousel-nav.prev { left: -8px; }
  .carousel-nav.next { right: -8px; }

  .slide-actions { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 0 8px 24px;
  }

  .palette-grid { grid-template-columns: repeat(3, 1fr); }

  .segmented-control .segment-badge { display: none; }

  #toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════
   SCROLLBAR GLOBAL OVERRIDE
════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ═══════════════════════════════════════════════════
   FOCUS VISIBLE (Accessibility)
════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
