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

:root {
  --purple-deep: #0d0618;
  --purple-dark: #1a0a2e;
  --purple-mid: #2d1b4e;
  --purple-light: #4a2c7a;
  --cyan-neon: #00d4ff;
  --pink-neon: #ff00ff;
  --gold: #ffd700;
  --gold-dim: #b8960f;
  --white: #f0f0f0;
  --gray: #888;
  --success: #00ff88;
  --error: #ff4444;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--purple-deep) 0%, #0a0515 50%, var(--purple-deep) 100%);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animations */
@keyframes glow {
  0%, 100% { text-shadow: 0 0 20px var(--cyan-neon), 0 0 40px var(--cyan-neon); }
  50% { text-shadow: 0 0 30px var(--pink-neon), 0 0 60px var(--pink-neon); }
}

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

/* Header */
.header {
  background: linear-gradient(180deg, var(--purple-dark) 0%, transparent 100%);
  padding: 1.5rem;
  border-bottom: 1px solid var(--purple-mid);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-neon), var(--pink-neon), transparent);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--cyan-neon), var(--pink-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glow 3s ease-in-out infinite;
}

.logo-icon {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  animation: float 3s ease-in-out infinite;
}

.tagline {
  font-size: 0.9rem;
  color: var(--gray);
  margin-top: 0.5rem;
  letter-spacing: 0.1em;
}

/* Main Container */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Setup Panel */
.setup-panel {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple-mid));
  border: 1px solid var(--purple-light);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.collapse-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--white);
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.3s;
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.collapse-icon {
  color: var(--cyan-neon);
}

.setup-content {
  padding: 1.5rem;
  border-top: 1px solid var(--purple-light);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 1rem;
}

.input-label {
  display: block;
  font-size: 0.8rem;
  color: var(--cyan-neon);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--purple-light);
  border-radius: 8px;
  color: var(--white);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  outline: none;
  border-color: var(--cyan-neon);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.text-input::placeholder,
.textarea-input::placeholder {
  color: var(--gray);
}

.select-input {
  cursor: pointer;
}

.select-input option {
  background: var(--purple-dark);
}

/* Chip Selector */
.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.4rem 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--purple-light);
  border-radius: 20px;
  color: var(--gray);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  border-color: var(--cyan-neon);
  color: var(--white);
}

.chip-selected {
  background: linear-gradient(135deg, var(--purple-light), var(--purple-mid));
  border-color: var(--cyan-neon);
  color: var(--cyan-neon);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* Slider */
.slider-container {
  margin-bottom: 1rem;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.slider {
  width: 100%;
  height: 6px;
  background: var(--purple-dark);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--cyan-neon), var(--pink-neon));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px var(--cyan-neon);
}

.slider-value {
  text-align: center;
  font-size: 0.9rem;
  color: var(--gold);
  margin-top: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
}

/* Checkbox */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--gray);
  transition: color 0.2s;
}

.checkbox-label:hover {
  color: var(--white);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan-neon);
}

/* Content Area */
.content-area {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.builder-section {
  flex: 1;
  min-width: 0;
}

/* Tab Panel */
.tab-panel {
  background: linear-gradient(135deg, var(--purple-dark), rgba(45, 27, 78, 0.5));
  border: 1px solid var(--purple-light);
  border-radius: 12px;
  overflow: hidden;
}

.tab-header {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--purple-light);
  overflow-x: auto;
}

.tab-button {
  flex: 1;
  min-width: 100px;
  padding: 1rem;
  background: transparent;
  border: none;
  color: var(--gray);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.tab-button:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.05);
}

.tab-active {
  color: var(--cyan-neon);
  background: rgba(0, 212, 255, 0.1);
}

.tab-active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan-neon), var(--pink-neon));
}

.tab-icon {
  font-size: 1.2rem;
}

.tab-content {
  padding: 1.5rem;
}

.tab-form {
  max-height: 400px;
  overflow-y: auto;
}

/* Prompt Preview */
.prompt-preview {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.4), rgba(26, 10, 46, 0.4));
  border: 1px solid var(--purple-light);
  border-radius: 12px;
  overflow: hidden;
}

.preview-header {
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid var(--purple-light);
}

.preview-header h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  color: var(--gold);
}

.preview-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.char-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--gray);
}

.quality-score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.score-bar {
  width: 60px;
  height: 6px;
  background: var(--purple-dark);
  border-radius: 3px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-neon), var(--success));
  transition: width 0.5s ease;
}

.score-value {
  color: var(--success);
  font-family: 'JetBrains Mono', monospace;
}

.prompt-code {
  padding: 1.5rem;
  max-height: 250px;
  overflow-y: auto;
}

.prompt-code pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--cyan-neon);
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-actions {
  padding: 1rem 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--purple-light);
  background: rgba(0, 0, 0, 0.2);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-neon), #0099cc);
  color: var(--purple-deep);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #00cc66) !important;
  animation: pulse 0.5s ease;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--pink-neon);
  color: var(--pink-neon);
}

.btn-secondary:hover {
  background: rgba(255, 0, 255, 0.1);
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

.btn-randomize:hover {
  animation: pulse 0.3s ease infinite;
}

.btn-save {
  width: 100%;
  margin-top: 1rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--purple-deep);
  font-size: 1rem;
  padding: 1rem;
}

.btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: linear-gradient(135deg, var(--purple-dark), var(--purple-mid));
  border: 1px solid var(--purple-light);
  border-radius: 12px;
  overflow: hidden;
  transition: width 0.3s ease;
  flex-shrink: 0;
}

.sidebar-collapsed {
  width: auto;
}

.sidebar-toggle {
  width: 100%;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: var(--cyan-neon);
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: background 0.3s;
}

.sidebar-toggle:hover {
  background: rgba(0, 212, 255, 0.1);
}

.sidebar-content {
  padding: 1rem;
}

.sidebar-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  color: var(--gold);
  margin-bottom: 1rem;
  text-align: center;
}

/* Library */
.library-toggle {
  position: fixed;
  bottom: 100px;
  right: 20px;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-light));
  border: 1px solid var(--cyan-neon);
  border-radius: 25px;
  color: var(--cyan-neon);
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s;
}

.library-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.library-panel {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 320px;
  max-height: 400px;
  background: var(--purple-dark);
  border: 1px solid var(--purple-light);
  border-radius: 12px;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.library-header {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--purple-light);
}

.library-header h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  color: var(--gold);
}

.close-btn {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--pink-neon);
}

.empty-state {
  padding: 2rem;
  text-align: center;
}

.pixel-character {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

.empty-state p {
  color: var(--gray);
  font-size: 0.9rem;
}

.library-list {
  max-height: 300px;
  overflow-y: auto;
}

.library-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--purple-mid);
  transition: background 0.2s;
}

.library-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.item-icon {
  font-size: 1.5rem;
  margin-right: 0.75rem;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-title {
  display: block;
  font-size: 0.9rem;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-date {
  font-size: 0.7rem;
  color: var(--gray);
}

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

.item-actions button {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.item-actions button:hover {
  opacity: 1;
}

/* Legendary Badge */
.legendary-badge {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--purple-deep);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  border-radius: 20px;
  animation: pulse 2s ease infinite;
  z-index: 1000;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  background: var(--purple-mid);
  border: 1px solid var(--purple-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast-success {
  border-color: var(--success);
}

.toast-icon {
  font-size: 1.2rem;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(180deg, transparent 0%, var(--purple-dark) 100%);
  border-top: 1px solid var(--purple-mid);
  text-align: center;
}

.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.footer-link {
  color: var(--pink-neon);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.footer-link:hover {
  text-shadow: 0 0 10px var(--pink-neon);
}

.version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--gray);
}

.footer-tip {
  font-size: 0.8rem;
  color: var(--gray);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  display: inline-block;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--purple-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--purple-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-neon);
}

/* Responsive */
@media (max-width: 1024px) {
  .content-area {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    order: -1;
  }
  
  .sidebar-collapsed {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .main-container {
    padding: 1rem;
  }
  
  .tab-label {
    display: none;
  }
  
  .tab-button {
    min-width: 60px;
    padding: 0.75rem;
  }
  
  .tab-icon {
    font-size: 1.5rem;
  }
  
  .preview-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .preview-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .library-panel {
    left: 20px;
    right: 20px;
    width: auto;
  }
  
  .library-toggle {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
  }
  
  .library-toggle:hover {
    transform: translateX(-50%) scale(1.05);
  }
}

@media (max-width: 480px) {
  .header {
    padding: 1rem;
  }
  
  .setup-content {
    padding: 1rem;
  }
  
  .tab-content {
    padding: 1rem;
  }
  
  .chip {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }
}