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

:root {
  --bg-dark: #0f0f1a;
  --bg-card: #1a1a2e;
  --accent-pink: #ff6b9d;
  --accent-purple: #a855f7;
  --accent-gold: #ffd93d;
  --accent-cyan: #00d4ff;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
}

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

.app-container {
  min-height: 100vh;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 107, 157, 0.15) 0%, transparent 50%),
    var(--bg-dark);
}

/* Header */
.header {
  padding: 2rem;
  text-align: center;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.record-emoji {
  display: inline-block;
  animation: spin 4s linear infinite;
  -webkit-text-fill-color: initial;
}

.record-emoji.reverse {
  animation-direction: reverse;
}

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

.subtitle {
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-size: 1.1rem;
}

.api-badge {
  display: inline-block;
  background: linear-gradient(135deg, #d97706, #dc2626);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-buttons {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
}

.history-toggle,
.settings-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: 2rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.history-toggle:hover,
.settings-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Settings Panel */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-content {
  background: var(--bg-card);
  border-radius: 1.5rem;
  padding: 2rem;
  max-width: 450px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.settings-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  color: var(--accent-gold);
}

.close-settings {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close-settings:hover {
  color: white;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-input {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 1rem;
  border-radius: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  transition: border-color 0.3s ease;
}

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

.settings-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.settings-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.settings-hint a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.settings-hint a:hover {
  text-decoration: underline;
}

.settings-model {
  font-size: 0.85rem;
  color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
}

.api-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fbbf24;
  padding: 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 1rem;
}

/* Main Content */
.main-content {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

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

/* Input Section */
.input-section {
  background: var(--bg-card);
  border-radius: 1.5rem;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--accent-gold);
}

.links-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.link-input-container {
  position: relative;
}

.link-input-container.valid .cassette-slot {
  box-shadow: 0 0 20px rgba(0, 255, 150, 0.3);
  border-color: rgba(0, 255, 150, 0.5);
}

.cassette-slot {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s ease;
}

.slot-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 60px;
}

.link-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.link-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.remove-btn {
  background: rgba(255, 100, 100, 0.2);
  border: none;
  color: #ff6b6b;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.remove-btn:hover {
  background: rgba(255, 100, 100, 0.4);
}

.add-track-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
  padding: 1rem;
  border-radius: 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.add-track-btn:hover {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
}

/* Mood Selector */
.mood-selector {
  margin-bottom: 2rem;
}

.mood-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mood-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mood-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  border-radius: 2rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.mood-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mood-btn.active {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  border-color: transparent;
  color: white;
  box-shadow: 0 5px 20px rgba(168, 85, 247, 0.4);
}

/* Generate Button */
.generate-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: white;
  padding: 1.25rem 2rem;
  border-radius: 1rem;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  transition: all 0.3s ease;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(168, 85, 247, 0.5);
}

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

.generate-btn.loading {
  animation: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4); }
  50% { box-shadow: 0 10px 40px rgba(255, 107, 157, 0.6); }
}

.loading-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

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

/* Disc Section */
.disc-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.vinyl-container {
  position: relative;
  width: 320px;
  height: 320px;
  cursor: pointer;
}

.vinyl-container.wobble .vinyl-disc {
  animation: wobble 0.5s ease-in-out;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}

.vinyl-container.disco-mode {
  animation: disco 0.3s ease-in-out infinite;
}

.vinyl-container.disco-mode::before {
  content: '🪩';
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 3rem;
  animation: spin 2s linear infinite;
  z-index: 10;
}

@keyframes disco {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(180deg); }
}

.vinyl-disc {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.3s ease;
}

.vinyl-disc.spinning {
  animation: spin 2s linear infinite;
}

.vinyl-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

.album-art-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-art-placeholder {
  font-size: 2rem;
}

.tonearm {
  position: absolute;
  top: -20px;
  right: 20px;
  transform-origin: top right;
  transition: transform 0.5s ease;
  transform: rotate(-30deg);
}

.tonearm.playing {
  transform: rotate(0deg);
}

.tonearm-base {
  width: 20px;
  height: 20px;
  background: #444;
  border-radius: 50%;
  position: absolute;
  top: 0;
  right: 0;
}

.tonearm-arm {
  width: 120px;
  height: 8px;
  background: linear-gradient(to right, #666, #444);
  position: absolute;
  top: 6px;
  right: 10px;
  transform-origin: right center;
  transform: rotate(-20deg);
  border-radius: 4px;
}

.tonearm-head {
  width: 20px;
  height: 15px;
  background: #333;
  position: absolute;
  top: 20px;
  right: 120px;
  border-radius: 3px;
}

.vinyl-shadow {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 20px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.4), transparent);
  border-radius: 50%;
}

/* Track Info */
.track-info {
  width: 100%;
  max-width: 350px;
}

.jewel-case {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  margin-bottom: 1.5rem;
}

.track-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.track-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.track-mood, .track-duration {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.inspired-by {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.inspired-label {
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.inspired-link {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

/* Audio Player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
}

.play-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(168, 85, 247, 0.5);
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
  border-radius: 6px;
  transition: width 0.1s linear;
}

.progress-grooves {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 4px,
    rgba(0, 0, 0, 0.2) 4px,
    rgba(0, 0, 0, 0.2) 5px
  );
}

.volume-knob {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #444, #222);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.knob-inner {
  width: 6px;
  height: 15px;
  background: var(--accent-gold);
  border-radius: 3px;
}

.download-btn {
  display: block;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 1rem;
  border-radius: 0.75rem;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.3s ease;
}

.download-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* History Panel */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 100;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.history-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
}

.close-history {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.history-item.active {
  border-color: var(--accent-pink);
  box-shadow: 0 0 20px rgba(255, 107, 157, 0.2);
}

.history-thumb {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.thumb-placeholder {
  font-size: 1.5rem;
}

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

.history-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.history-mood {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer p {
  margin-bottom: 0.5rem;
}

.remix-link {
  color: var(--accent-pink);
  text-decoration: none;
  transition: color 0.3s ease;
}

.remix-link:hover {
  color: var(--accent-purple);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
  .header {
    padding: 1.5rem 1rem;
  }

  .header-buttons {
    position: static;
    margin-top: 1rem;
    justify-content: center;
  }

  .history-toggle,
  .settings-toggle {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }

  .main-content {
    padding: 1rem;
  }

  .input-section {
    padding: 1.5rem;
  }

  .vinyl-container {
    width: 280px;
    height: 280px;
  }

  .mood-btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .history-panel {
    width: 100%;
  }
}