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

:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #141428;
  --bg-panel: #1a1a35;
  --accent-pink: #e94560;
  --accent-cyan: #00d9ff;
  --accent-green: #8fd34a;
  --accent-blue: #4a90e2;
  --accent-magenta: #ff00ff;
  --text-primary: #e0e0e0;
  --text-muted: #888;
  --glow-cyan: 0 0 20px rgba(0, 217, 255, 0.4);
  --glow-pink: 0 0 20px rgba(233, 69, 96, 0.4);
}

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

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(ellipse at 20% 0%, rgba(233, 69, 96, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 217, 255, 0.1) 0%, transparent 50%),
    var(--bg-primary);
}

.app-header {
  padding: 1.5rem 2rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, rgba(20, 20, 40, 0.8) 0%, transparent 100%);
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
}

.app-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.title-emoji {
  font-size: 2.5rem;
  animation: pulse 2s infinite;
}

.title-text {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-pink) 50%, var(--accent-magenta) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: var(--glow-cyan);
  animation: glow 3s ease-in-out infinite alternate;
}

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

@keyframes glow {
  from { filter: drop-shadow(0 0 10px rgba(0, 217, 255, 0.4)); }
  to { filter: drop-shadow(0 0 20px rgba(233, 69, 96, 0.4)); }
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.panels-container {
  gap: 1.5rem;
}

.desktop-layout {
  display: none;
}

.mobile-layout {
  display: block;
}

@media (min-width: 1024px) {
  .desktop-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
  }
  .mobile-layout {
    display: none;
  }
  .mobile-nav {
    display: none !important;
  }
}

.panel {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topic-input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.topic-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

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

.duration-buttons, .vibe-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.duration-btn, .vibe-btn {
  padding: 0.625rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.duration-btn.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #000;
  font-weight: 600;
}

.vibe-btn.active {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-magenta));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

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

.template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.875rem 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-btn:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.template-btn.active {
  background: rgba(74, 144, 226, 0.2);
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(74, 144, 226, 0.3);
}

.template-icon {
  font-size: 1.5rem;
}

.template-name {
  font-size: 0.75rem;
  font-weight: 500;
}

.generate-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-magenta) 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--glow-pink);
}

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

.generate-btn.generating {
  animation: pulse 1s infinite;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.character-key {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.key-item {
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.script-table {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.script-row {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1rem;
  border-left: 3px solid var(--accent-blue);
  transition: all 0.2s ease;
}

.script-row:hover {
  background: rgba(0, 0, 0, 0.3);
}

.script-row.hook-row {
  border-left-color: var(--accent-pink);
  background: rgba(233, 69, 96, 0.1);
}

.time-col {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent-cyan);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.content-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.visual-row, .audio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 50px;
}

.overlay-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-magenta));
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.copy-btn {
  padding: 0.5rem 0.875rem;
  background: rgba(0, 217, 255, 0.1);
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: var(--accent-cyan);
  color: #000;
}

.thumbnail-section, .caption-section, .rules-section {
  margin-bottom: 1.5rem;
}

.thumbnail-section h3, .caption-section h3, .rules-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
  color: var(--text-muted);
}

.thumbnail-preview {
  aspect-ratio: 16/9;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
  position: relative;
  overflow: hidden;
}

.thumbnail-preview.neon {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.thumbnail-preview.dark {
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.thumbnail-preview.light {
  background: linear-gradient(135deg, #f0f0f0 0%, #ffffff 100%);
  border: 2px solid #ddd;
}

.thumbnail-preview.light .thumbnail-text,
.thumbnail-preview.light .thumbnail-subtext {
  color: #1a1a2e;
}

.thumbnail-text {
  font-size: 1.75rem;
  font-weight: 900;
  text-shadow: 0 0 20px var(--accent-cyan), 0 0 40px var(--accent-pink);
  text-align: center;
  padding: 0 1rem;
}

.thumbnail-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.thumbnail-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 0.625rem;
}

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

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

.scheme-btn {
  flex: 1;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.caption-preview {
  background: #000;
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
}

.caption-words {
  text-align: center;
  line-height: 1.8;
  font-size: 1.1rem;
  font-weight: 600;
}

.animated-word {
  display: inline-block;
  animation: popIn 0.15s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.caption-controls {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.control-btn {
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.speed-control {
  flex: 1;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-control label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.speed-control input[type="range"] {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-cyan);
  border-radius: 50%;
  cursor: pointer;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

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

.rule-item input[type="text"] {
  flex: 1;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
}

.rule-item input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.remove-rule {
  width: 28px;
  height: 28px;
  background: rgba(233, 69, 96, 0.2);
  border: 1px solid var(--accent-pink);
  border-radius: 6px;
  color: var(--accent-pink);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-rule:hover {
  background: var(--accent-pink);
  color: #fff;
}

.add-rule-btn {
  width: 100%;
  padding: 0.625rem;
  background: rgba(0, 217, 255, 0.1);
  border: 1px dashed var(--accent-cyan);
  border-radius: 8px;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-rule-btn:hover {
  background: rgba(0, 217, 255, 0.2);
}

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-panel);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  padding: 0.875rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.nav-btn.active {
  background: rgba(0, 217, 255, 0.2);
}

.bottom-toolbar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  flex-wrap: wrap;
  margin-bottom: 60px;
}

@media (min-width: 1024px) {
  .bottom-toolbar {
    margin-bottom: 0;
  }
}

.export-btn {
  padding: 0.625rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  background: rgba(0, 217, 255, 0.1);
}

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

.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.app-footer a {
  color: var(--accent-pink);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

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

@media (max-width: 640px) {
  .app-header {
    padding: 1rem;
  }
  
  .app-title {
    font-size: 1.5rem;
  }
  
  .title-emoji {
    font-size: 1.75rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .panel {
    padding: 1.25rem;
  }
  
  .template-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .thumbnail-text {
    font-size: 1.25rem;
  }
}