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

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  line-height: 1.6;
}

/* Theme Variables */
.theme-dark {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --border-color: #30363d;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --glow-color: rgba(139, 92, 246, 0.5);
  --glass-bg: rgba(22, 27, 34, 0.8);
}

.theme-light {
  --bg-primary: #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f0;
  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-muted: #8b949e;
  --border-color: #d0d7de;
  --accent-purple: #8b5cf6;
  --accent-cyan: #0891b2;
  --glow-color: rgba(139, 92, 246, 0.3);
  --glass-bg: rgba(255, 255, 255, 0.9);
}

.theme-dark, .theme-light {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Turbo Mode */
.turbo-mode {
  animation: turbo-pulse 2s ease-in-out infinite;
}

.turbo-mode::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, 
    rgba(139, 92, 246, 0.05) 0%,
    rgba(6, 182, 212, 0.05) 50%,
    rgba(139, 92, 246, 0.05) 100%
  );
  pointer-events: none;
  z-index: 0;
}

@keyframes turbo-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.05); }
}

/* Header */
.header-container {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border-bottom: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.header-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan), var(--accent-purple));
  background-size: 200% 100%;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.header-icon {
  color: var(--accent-purple);
}

.app-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-tagline {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.theme-toggle, .sidebar-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover, .sidebar-toggle:hover {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
}

/* Input Section */
.input-section {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
}

.platform-icons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  justify-content: center;
}

.platform-icon {
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  transition: all 0.3s ease;
  opacity: 0.5;
}

.platform-icon.active {
  opacity: 1;
  background: var(--bg-secondary);
  box-shadow: 0 0 20px var(--glow-color);
  transform: scale(1.1);
}

.url-input-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.url-input {
  width: 100%;
  padding: 16px 50px 16px 20px;
  font-size: 1rem;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.url-input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 30px var(--glow-color);
}

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

.copy-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

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

.analyze-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.125rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 40px var(--glow-color);
}

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

.analyze-btn.analyzing {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Preview Card */
.preview-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  animation: slide-up 0.5s ease;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thumbnail-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  min-width: 200px;
}

.thumbnail {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.thumbnail-wrapper:hover .play-overlay {
  opacity: 1;
}

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}

.platform-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px;
  border-radius: 6px;
}

.video-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.channel-name {
  color: var(--accent-cyan);
  font-weight: 500;
  margin-bottom: 4px;
}

.video-meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Options Panel */
.options-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  animation: slide-up 0.5s ease 0.1s both;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 12px;
}

.tab {
  flex: 1;
  padding: 12px;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.option-card {
  padding: 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.option-card:hover {
  border-color: var(--accent-purple);
  transform: translateY(-2px);
}

.option-card.selected {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.option-resolution {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.option-details {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Waveform */
.waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  margin-bottom: 16px;
}

.waveform-bar {
  width: 4px;
  background: linear-gradient(180deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% { height: 10px; }
  50% { height: 30px; }
}

/* Download Button */
.download-btn {
  width: 100%;
  padding: 18px;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--accent-purple), #a855f7);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.download-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 50px var(--glow-color);
}

.download-btn.downloading {
  background: var(--bg-tertiary);
  cursor: wait;
}

.download-btn.complete {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  transition: width 0.05s linear;
  border-radius: 12px;
}

.download-btn-text {
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 280px;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: var(--bg-secondary);
    z-index: 100;
    padding: 80px 20px 20px;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  }
  
  .sidebar.open {
    right: 0;
  }
}

.sidebar-section {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.platforms-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.platform-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  color: var(--text-secondary);
  transition: all 0.3s;
  cursor: pointer;
}

.platform-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  transform: scale(1.1);
}

.empty-history {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  font-style: italic;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  transition: all 0.2s;
}

.history-item:hover {
  background: var(--bg-primary);
}

.history-thumb {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
}

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

.history-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  margin-top: 40px;
}

.footer-credit {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.remix-link {
  display: inline-block;
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 8px;
  transition: color 0.2s;
}

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

.footer-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

.confetti-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall linear forwards;
}

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

/* Toast Animation */
@keyframes animate-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in {
  animation: animate-slide-in 0.3s ease;
}

/* Responsive */
@media (max-width: 640px) {
  .app-title {
    font-size: 1.25rem;
  }
  
  .options-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .thumbnail-wrapper {
    min-width: 100%;
  }
}