:root {
  --deep-purple: #2D1B4E;
  --electric-blue: #3B82F6;
  --accent-pink: #EC4899;
  --soft-white: #F8FAFC;
  --bg-dark: #0D0A14;
  --card-bg: rgba(45, 27, 78, 0.6);
  --glass: rgba(255, 255, 255, 0.05);
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-dark);
  color: var(--soft-white);
  min-height: 100vh;
  background-image: 
    radial-gradient(ellipse at top, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--deep-purple) 0%, #1a103a 100%);
  padding: 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.header-content {
  position: relative;
  z-index: 1;
}

.app-title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--soft-white) 0%, var(--accent-pink) 50%, var(--electric-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.title-icon {
  font-size: 1.5rem;
  -webkit-text-fill-color: initial;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.2) rotate(15deg); }
}

.tagline {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: rgba(248, 250, 252, 0.7);
  font-family: 'Crimson Pro', serif;
  font-style: italic;
}

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

/* Prompt Section */
.prompt-section {
  margin-bottom: 2rem;
}

.textarea-wrapper {
  position: relative;
}

.prompt-input {
  width: 100%;
  padding: 1.25rem;
  background: var(--card-bg);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  color: var(--soft-white);
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.prompt-input:focus {
  outline: none;
  border-color: var(--electric-blue);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
}

.prompt-input::placeholder {
  color: rgba(248, 250, 252, 0.4);
}

.textarea-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0 0.5rem;
}

.char-count {
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.5);
}

.clear-btn {
  background: none;
  border: none;
  color: rgba(248, 250, 252, 0.5);
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.2s;
}

.clear-btn:hover {
  color: var(--accent-pink);
}

/* Recent Prompts */
.recent-prompts {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1rem 0;
}

.recent-label {
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.5);
}

.recent-chip {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(248, 250, 252, 0.7);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.recent-chip:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--electric-blue);
}

/* Presets */
.presets-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  justify-content: center;
}

.preset-chip {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--soft-white);
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.preset-chip:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(236, 72, 153, 0.3));
  border-color: var(--accent-pink);
  transform: translateY(-2px);
}

/* Action Row */
.action-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.inspire-btn {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--soft-white);
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}

.inspire-btn:hover {
  background: rgba(236, 72, 153, 0.2);
  border-color: var(--accent-pink);
}

.generate-btn {
  background: linear-gradient(135deg, var(--deep-purple) 0%, var(--electric-blue) 100%);
  border: none;
  color: var(--soft-white);
  padding: 1rem 2.5rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.generate-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 30px rgba(59, 130, 246, 0.5);
}

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

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

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Pattern Section */
.pattern-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.pattern-frame {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 3/4;
  background: var(--card-bg);
  border-radius: 20px;
  border: 3px solid rgba(255,255,255,0.1);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  position: relative;
}

.pattern-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.pattern-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(248, 250, 252, 0.4);
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.pattern-skeleton {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--deep-purple) 0%, #1a103a 100%);
  position: relative;
  overflow: hidden;
}

.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.1) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Pattern Actions */
.pattern-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--soft-white);
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

.action-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--electric-blue);
  transform: translateY(-2px);
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--electric-blue) 100%);
  border: none;
}

/* Gallery Toggle */
.gallery-toggle {
  background: none;
  border: none;
  color: rgba(248, 250, 252, 0.7);
  font-size: 1rem;
  cursor: pointer;
  padding: 1rem;
  width: 100%;
  text-align: left;
  transition: color 0.2s;
}

.gallery-toggle:hover {
  color: var(--soft-white);
}

/* Gallery */
.gallery-section {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.gallery-empty {
  text-align: center;
  color: rgba(248, 250, 252, 0.5);
  padding: 2rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.gallery-item {
  aspect-ratio: 3/4;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.3s;
}

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

.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));
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.75rem;
}

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

.gallery-overlay p {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 0.5rem;
}

.delete-btn {
  background: rgba(239, 68, 68, 0.8);
  border: none;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  align-self: flex-start;
}

.clear-all-btn {
  margin-top: 1rem;
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: rgb(239, 68, 68);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.clear-all-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  max-width: 500px;
  width: 100%;
  background: var(--card-bg);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(20px);
}

.modal-content img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.modal-prompt {
  padding: 1.5rem;
  font-size: 0.9rem;
  color: rgba(248, 250, 252, 0.8);
  font-family: 'Crimson Pro', serif;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.5);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 10;
}

/* Footer */
.app-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.3);
}

.pattern-count {
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.5);
  margin-bottom: 0.5rem;
}

.tip {
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.6);
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  margin-bottom: 1rem;
  animation: fadeIn 0.5s ease;
}

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

.footer-link:hover {
  color: var(--electric-blue);
}

/* Toast */
.toast-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--deep-purple), var(--electric-blue));
  color: white;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  z-index: 200;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .app-title {
    font-size: 1.5rem;
  }
  
  .generate-btn {
    width: 100%;
    padding: 1rem;
  }
  
  .pattern-frame {
    max-width: 300px;
  }
  
  .action-row {
    flex-direction: column;
  }
  
  .inspire-btn {
    width: 100%;
  }
}