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

:root {
  --space-black: #0a0a0a;
  --imperial-gray: #2d2d2d;
  --saber-blue: #4fc3f7;
  --saber-red: #f44336;
  --saber-green: #66bb6a;
  --hologram-cyan: #00fff7;
  --crawl-yellow: #ffe81f;
  --panel-bg: rgba(20, 20, 25, 0.95);
}

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--space-black);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  position: relative;
  min-height: 100vh;
}

.content-wrapper {
  position: relative;
  z-index: 10;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 40px 20px 20px;
}

.main-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 900;
  background: linear-gradient(180deg, var(--crawl-yellow) 0%, #ffa000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(255, 232, 31, 0.5);
  letter-spacing: 2px;
  margin-bottom: 10px;
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(255, 232, 31, 0.3)); }
  50% { filter: drop-shadow(0 0 40px rgba(255, 232, 31, 0.6)); }
}

.subtitle {
  font-family: 'Audiowide', cursive;
  font-size: clamp(0.8rem, 2vw, 1.1rem);
  color: var(--hologram-cyan);
  text-transform: uppercase;
  letter-spacing: 4px;
  opacity: 0.9;
}

/* Lightsaber Divider */
.lightsaber-divider {
  width: 100%;
  height: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightsaber-blade {
  width: 60%;
  height: 3px;
  border-radius: 2px;
  animation: saberPulse 2s ease-in-out infinite;
}

@keyframes saberPulse {
  0%, 100% { opacity: 0.8; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.02); }
}

/* Sections */
.section {
  background: var(--panel-bg);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 
    0 4px 30px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.dark-side .section {
  border-color: rgba(244, 67, 54, 0.3);
}

.section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--crawl-yellow);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.template-card {
  background: rgba(45, 45, 45, 0.8);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.template-card:hover {
  border-color: var(--saber-blue);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(79, 195, 247, 0.2);
}

.template-card.selected {
  border-color: var(--crawl-yellow);
  background: rgba(255, 232, 31, 0.1);
  box-shadow: 0 0 20px rgba(255, 232, 31, 0.3);
}

.dark-side .template-card:hover {
  border-color: var(--saber-red);
  box-shadow: 0 5px 20px rgba(244, 67, 54, 0.2);
}

.template-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.template-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.template-caption {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.3;
}

/* Custom Prompt */
.custom-prompt-container {
  margin-top: 16px;
}

.custom-prompt-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--saber-blue);
  border-radius: 8px;
  padding: 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.custom-prompt-input:focus {
  outline: none;
  border-color: var(--crawl-yellow);
  box-shadow: 0 0 15px rgba(255, 232, 31, 0.2);
}

/* Political Controls */
.political-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.political-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.political-select,
.political-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 232, 31, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
}

.political-select:focus,
.political-input:focus {
  outline: none;
  border-color: var(--crawl-yellow);
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.toggle-switch {
  position: relative;
  width: 60px;
  height: 28px;
  background: rgba(45, 45, 45, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  cursor: pointer;
  overflow: hidden;
}

.toggle-indicator {
  position: absolute;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px currentColor;
}

.toggle-indicator.left {
  left: 2px;
}

.toggle-indicator.right {
  left: 34px;
}

.toggle-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.1;
  transition: opacity 0.3s ease;
}

.toggle-switch:hover .toggle-glow {
  opacity: 0.2;
}

/* Caption Inputs */
.caption-inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.caption-group {
  position: relative;
}

.caption-label {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--saber-blue);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.dark-side .caption-label {
  color: var(--saber-red);
}

.caption-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 8px;
  padding: 14px;
  padding-right: 60px;
  color: #fff;
  font-family: 'Audiowide', cursive;
  font-size: 1rem;
}

.caption-input:focus {
  outline: none;
  border-color: var(--saber-blue);
  box-shadow: 0 0 15px rgba(79, 195, 247, 0.2);
}

.dark-side .caption-input {
  border-color: rgba(244, 67, 54, 0.3);
}

.dark-side .caption-input:focus {
  border-color: var(--saber-red);
  box-shadow: 0 0 15px rgba(244, 67, 54, 0.2);
}

.char-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
}

/* API Toggle */
.api-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.api-description {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

/* Generate Button */
.generate-section {
  text-align: center;
  padding: 20px 0;
}

.generate-button {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #b71c1c 0%, #f44336 50%, #b71c1c 100%);
  border: 3px solid #ff5252;
  border-radius: 50px;
  padding: 18px 40px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 
    0 0 30px rgba(244, 67, 54, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(244, 67, 54, 0.4); }
  50% { box-shadow: 0 0 50px rgba(244, 67, 54, 0.7); }
}

.generate-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 60px rgba(244, 67, 54, 0.6);
}

.generate-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  animation: none;
}

.loading-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

/* Result Section */
.result-section {
  text-align: center;
}

.image-container {
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid var(--saber-blue);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  overflow: hidden;
}

.dark-side .image-container {
  border-color: var(--saber-red);
}

.generated-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  animation: hologramFlicker 4s ease-in-out infinite;
}

@keyframes hologramFlicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  96% { opacity: 0.9; }
  97% { opacity: 1; }
}

.image-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.action-button {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.action-button.download {
  background: linear-gradient(135deg, #1565c0, #42a5f5);
  border: 2px solid var(--saber-blue);
  color: #fff;
}

.action-button.download:hover {
  box-shadow: 0 0 20px rgba(79, 195, 247, 0.5);
  transform: translateY(-2px);
}

.action-button.regenerate {
  background: transparent;
  border: 2px solid var(--crawl-yellow);
  color: var(--crawl-yellow);
}

.action-button.regenerate:hover {
  background: rgba(255, 232, 31, 0.1);
  box-shadow: 0 0 20px rgba(255, 232, 31, 0.3);
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

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

.gallery-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.gallery-item:hover {
  border-color: var(--saber-blue);
  transform: scale(1.05);
}

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

/* Settings */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Footer */
.footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 40px;
}

.footer-tagline {
  font-family: 'Audiowide', cursive;
  font-size: 1.2rem;
  color: var(--crawl-yellow);
  margin-bottom: 12px;
}

.footer-disclaimer {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 16px;
}

.footer-link {
  display: inline-block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  color: var(--hologram-cyan);
  text-decoration: none;
  padding: 10px 20px;
  border: 1px solid var(--hologram-cyan);
  border-radius: 20px;
  transition: all 0.3s ease;
}

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

/* Mobile Responsive */
@media (max-width: 600px) {
  .content-wrapper {
    padding: 12px;
  }
  
  .section {
    padding: 16px;
  }
  
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .political-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .generate-button {
    font-size: 0.9rem;
    padding: 14px 28px;
  }
  
  .image-actions {
    flex-direction: column;
  }
  
  .action-button {
    width: 100%;
  }
}