:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #12121a;
  --bg-surface: #1a1a2e;
  --bg-elevated: #252538;
  --accent-purple: #9d4edd;
  --accent-cyan: #00d9ff;
  --accent-pink: #ff006e;
  --accent-green: #00ff88;
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #555566;
  --border: #2a2a40;
  --glass: rgba(30, 30, 50, 0.7);
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(157, 78, 221, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 217, 255, 0.05) 0%, transparent 50%),
    var(--bg-dark);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.5rem;
  animation: wiggle 3s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge {
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  color: var(--bg-dark);
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: var(--bg-surface);
}

.header-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-gradient {
  height: 2px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan), var(--accent-pink));
  animation: shimmer 3s linear infinite;
}

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

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Panels */
.panel {
  background: var(--bg-panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Image Panel */
.image-panel {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  min-height: calc(100vh - 200px);
}

.panel-main {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Prompt Section */
.prompt-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.prompt-actions {
  display: flex;
  gap: 0.5rem;
}

.template-select {
  padding: 0.4rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.prompt-input {
  width: 100%;
  min-height: 100px;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.2s;
}

.prompt-input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

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

.prompt-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Quick Settings */
.quick-settings {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.select-sm {
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.aspect-group {
  flex: 1;
}

.aspect-buttons {
  display: flex;
  gap: 0.25rem;
}

.aspect-btn {
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.aspect-btn:first-child { border-radius: 8px 0 0 8px; }
.aspect-btn:last-child { border-radius: 0 8px 8px 0; }

.aspect-btn:hover {
  background: var(--bg-elevated);
}

.aspect-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

/* Style Presets */
.style-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.style-btn:hover {
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

.style-btn.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(0, 217, 255, 0.1);
}

.style-emoji {
  font-size: 1.25rem;
}

/* Advanced Settings */
.advanced-settings {
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.seed-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.seed-input,
.input-sm {
  flex: 1;
  min-width: 150px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-elevated);
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.btn-secondary {
  background: transparent;
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(157, 78, 221, 0.1);
}

.btn-danger {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 0, 110, 0.1);
}

.btn-icon {
  padding: 0.5rem;
  min-width: 40px;
}

.btn-generate {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: white;
  position: relative;
  overflow: hidden;
}

.btn-generate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-generate:hover:not(:disabled)::before {
  opacity: 1;
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(157, 78, 221, 0.3);
}

.btn-generate.generating {
  background: var(--bg-surface);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.loading-text {
  font-style: italic;
}

/* Preview Area */
.preview-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: var(--bg-surface);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.loading-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.loading-gradient {
  width: 200px;
  height: 200px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan), var(--accent-pink));
  animation: rotate 2s linear infinite, pulse 1.5s ease-in-out infinite;
}

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

.loading-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

.empty-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.image-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}

.generated-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.image-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Sidebar */
.sidebar {
  padding: 1.5rem;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 500;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item:hover {
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text-primary);
}

/* Text Panel */
.text-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
}

.text-header {
  padding: 1rem 1.5rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
}

.slider-sm {
  width: 100px;
  accent-color: var(--accent-cyan);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  width: 100px;
}

.system-prompt-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.system-input {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

.quick-actions {
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.quick-action-btn {
  padding: 0.4rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.messages-container {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.message {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  position: relative;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-content {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.copy-btn:hover {
  opacity: 1;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  display: flex;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 150px;
}

.btn-send {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none;
  color: var(--bg-dark);
}

/* Audio Panel */
.audio-panel {
  padding: 2rem;
  min-height: calc(100vh - 200px);
}

.audio-content {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.audio-input {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}

.voice-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.voice-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.voice-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: capitalize;
  transition: all 0.2s;
}

.voice-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

.audio-player {
  width: 100%;
  border-radius: 8px;
}

/* Gallery Panel */
.gallery-panel {
  min-height: calc(100vh - 200px);
}

.gallery-header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.gallery-filters {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

.empty-gallery {
  padding: 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.8));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-overlay {
  opacity: 1;
}

.gallery-prompt {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.fav-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 4px;
  font-size: 1.25rem;
  cursor: pointer;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
}

.lightbox-info {
  background: var(--bg-panel);
  padding: 1rem;
  border-radius: 12px;
}

.lightbox-prompt {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.lightbox-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.lightbox-actions {
  display: flex;
  gap: 0.5rem;
}

.lightbox-close {
  position: absolute;
  top: -1rem;
  right: -1rem;
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer */
.footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

.footer-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.status.online {
  color: var(--accent-green);
}

/* Confetti */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .image-panel {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 200px;
  }
  
  .header-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .tab-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }
}

@media (max-width: 600px) {
  .main-content {
    padding: 1rem;
  }
  
  .prompt-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .quick-settings {
    flex-direction: column;
    align-items: stretch;
  }
  
  .aspect-buttons {
    flex-wrap: wrap;
  }
  
  .message {
    max-width: 95%;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
  }
}