:root {
  --bg: #0d0d1a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --accent: #7c3aed;
  --accent2: #a78bfa;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #2d2d4e;
  --success: #10b981;
  --danger: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #7c3aed, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header h1 span { font-weight: 400; font-size: 1.4rem; }

header p { color: var(--text-muted); margin-top: 0.5rem; }

main { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; }

@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

/* Panel */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
}

section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent2);
}

section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

section h3 small { font-size: 0.75rem; color: var(--accent2); text-transform: none; }

/* Generation Tabs */
.gen-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.gen-tab {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.gen-tab:hover { border-color: var(--accent2); color: var(--accent2); }
.gen-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

.tab-panel { }

/* Image Upload */
.image-upload-area {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s;
  overflow: hidden;
  min-height: 120px;
  position: relative;
}

.image-upload-area:hover,
.image-upload-area.drag-over { border-color: var(--accent); }

.image-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  min-height: 120px;
  text-align: center;
}

.upload-icon { font-size: 2rem; }
.upload-hint { font-size: 0.72rem; opacity: 0.6; }

.image-upload-area img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
  background: var(--surface2);
}

/* Input */
.input-group { display: flex; flex-direction: column; gap: 0.75rem; }

textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  color: var(--text);
  padding: 0.875rem;
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.2s;
}

textarea:focus { outline: none; border-color: var(--accent); }
textarea::placeholder { color: var(--text-muted); }

/* Buttons */
.btn {
  border: none;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.75rem 1.25rem;
  transition: all 0.2s;
  font-family: inherit;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: white;
  width: 100%;
}

.btn.primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.export {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  flex: 1;
}

.btn.export:hover { border-color: var(--accent2); color: var(--accent2); }
.btn.record { border-color: var(--danger); color: var(--danger); }
.btn.stop { border-color: var(--success); color: var(--success); }

/* Character Grid */
.saved-characters { margin-top: 1.5rem; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.character-thumb {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.character-thumb:hover { border-color: var(--accent2); }
.character-thumb.active { border-color: var(--accent); }

.character-thumb svg { width: 100%; height: 100%; }

.character-thumb .delete-btn {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.character-thumb:hover .delete-btn { display: flex; }

/* Stage */
.stage-wrapper {
  margin-bottom: 1.25rem;
  position: relative;
  perspective: 900px;
  overflow: visible;
}

.stage {
  background: repeating-conic-gradient(#1e1e3a 0% 25%, #252545 0% 50%) 0 0 / 20px 20px;
  border-radius: 0.75rem;
  height: 470px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  border: 1px solid var(--border);
  cursor: crosshair;
}

.stage.bg-gradient {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
}

.character-display {
  width: 280px;
  height: 455px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.character-display svg { width: 100%; height: 100%; }

.placeholder-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Animation buttons */
.anim-buttons, .variant-buttons, .bg-buttons, .export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.anim-btn, .variant-btn, .bg-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.anim-btn:hover, .variant-btn:hover, .bg-btn:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

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

/* Recording */
.recording-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

.rec-dot {
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem 3rem;
  text-align: center;
}

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Character animations: GSAP handles all anim-* buttons */
