* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Light Mode (Default) */
body.light-mode {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.light-mode .container {
  background: white;
  color: #333;
}

body.light-mode input[type="text"] {
  background: white;
  border-color: #e0e0e0;
  color: #333;
}

body.light-mode input[type="text"]::placeholder {
  color: #aaa;
}

body.light-mode select {
  background: white;
  border-color: #e0e0e0;
  color: #333;
}

body.light-mode .media-info {
  background: #f8f9fa;
}

body.light-mode .progress-bar-container {
  background: #e0e0e0;
}

body.light-mode .progress-bar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Dark Mode */
body.dark-mode {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .container {
  background: #1e1e2f;
  color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.dark-mode input[type="text"] {
  background: #2d2d44;
  border-color: #404060;
  color: #e0e0e0;
}

body.dark-mode input[type="text"]:focus {
  border-color: #7b2eda;
}

body.dark-mode input[type="text"]::placeholder {
  color: #666;
}

body.dark-mode select {
  background: #2d2d44;
  border-color: #404060;
  color: #e0e0e0;
}

body.dark-mode .media-info {
  background: #2a2a40;
}

body.dark-mode .media-details h3 {
  color: #e0e0e0;
}

body.dark-mode .media-details p {
  color: #a0a0c0;
}

body.dark-mode .progress-bar-container {
  background: #404060;
}

body.dark-mode .progress-bar {
  background: linear-gradient(135deg, #7b2eda 0%, #a55eea 100%);
}

body.dark-mode .error {
  background: #442222;
  color: #ffaaaa;
  border-left-color: #ff5555;
}

body.dark-mode .success {
  background: #224422;
  color: #aaffaa;
  border-left-color: #55ff55;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.theme-btn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s;
}

.theme-btn:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.3);
}

.light-mode .light-icon,
.dark-mode .dark-icon {
  display: inline-block;
}

.light-mode .dark-icon,
.dark-mode .light-icon {
  display: none;
}

/* Container */
.container {
  border-radius: 20px;
  padding: 50px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 650px;
  width: 100%;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.logo-icon {
  font-size: 2.5em;
}

.logo h1 {
  font-size: 2.5em;
  margin: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.dark-mode .logo h1 {
  background: linear-gradient(135deg, #7b2eda 0%, #a55eea 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 1em;
  opacity: 0.7;
  margin-top: 5px;
}

/* Input Section */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

/* URL Input with Fetch Button */
.url-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.url-input-wrapper input[type="text"] {
  flex: 1;
  padding: 15px 18px;
  border: 2px solid;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s;
  width: 100%;
}

.url-input-wrapper input[type="text"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
  border-color: #667eea;
}

.fetch-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 25px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 120px;
  justify-content: center;
}

.fetch-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(118, 75, 162, 0.4);
}

.fetch-btn:active {
  transform: translateY(0);
}

.fetch-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.fetch-icon {
  font-size: 18px;
}

.fetch-loader {
  font-size: 18px;
}

/* Options Section */
.options-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  padding: 15px;
  background: rgba(118, 75, 162, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(118, 75, 162, 0.2);
}

body.dark-mode .options-section {
  background: rgba(118, 75, 162, 0.15);
  border-color: rgba(118, 75, 162, 0.3);
}

.format-selector,
.quality-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.format-selector label,
.quality-selector label {
  font-weight: 600;
  font-size: 0.95em;
  color: #555;
}

body.dark-mode .format-selector label,
body.dark-mode .quality-selector label {
  color: #b0b0d0;
}

#format,
#quality {
  padding: 10px 12px;
  border: 2px solid;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.3s;
  font-weight: 500;
}

#format:focus,
#quality:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(118, 75, 162, 0.1);
}

/* Download Button */
.download-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.download-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(118, 75, 162, 0.4);
}

.download-btn:active:not(:disabled) {
  transform: translateY(0);
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.download-btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.download-icon {
  font-size: 20px;
}

.download-loader {
  font-size: 18px;
  animation: spin 1s linear infinite;
}

/* Media Info */
.media-info {
  display: flex;
  gap: 20px;
  padding: 20px;
  border-radius: 12px;
  margin: 20px 0;
  align-items: center;
  border: 1px solid rgba(118, 75, 162, 0.2);
}

.media-preview {
  flex-shrink: 0;
}

.media-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
}

.media-details {
  flex: 1;
}

.media-details h3 {
  margin-bottom: 8px;
  font-size: 1.1em;
  color: #333;
}

body.dark-mode .media-details h3 {
  color: #e0e0e0;
}

.media-details p {
  font-size: 0.9em;
  opacity: 0.8;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Progress Section */
.progress-section {
  margin-top: 20px;
  padding: 20px;
  border-radius: 12px;
  background: rgba(118, 75, 162, 0.1);
  border: 1px solid rgba(118, 75, 162, 0.2);
}

body.dark-mode .progress-section {
  background: rgba(118, 75, 162, 0.15);
  border-color: rgba(118, 75, 162, 0.3);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.95em;
}

.progress-bar-container {
  width: 100%;
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
  height: 100%;
  transition: width 0.3s ease;
  box-shadow: 0 2px 8px rgba(118, 75, 162, 0.3);
}

/* Loading Spinner */
.loading {
  text-align: center;
  margin-top: 30px;
  padding: 30px;
}

.spinner {
  border: 4px solid rgba(118, 75, 162, 0.2);
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
  color: #667eea;
  font-weight: 500;
}

body.dark-mode .loading p {
  color: #7b2eda;
}

/* Messages */
.error,
.success {
  padding: 15px 18px;
  border-radius: 10px;
  margin-top: 20px;
  text-align: center;
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
  font-weight: 500;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error {
  background: #fee8e8;
  color: #c33;
  border-left-color: #ff5555;
}

.success {
  background: #e8f5e8;
  color: #2e7d32;
  border-left-color: #4caf50;
}

.hidden {
  display: none;
}

/* Responsive design for mobile */
@media (max-width: 600px) {
  .container {
    padding: 30px 20px;
  }
  
  .logo h1 {
    font-size: 2em;
  }
  
  .tagline {
    font-size: 0.9em;
  }
  
  .url-input-wrapper {
    flex-direction: column;
  }
  
  .fetch-btn {
    width: 100%;
  }
  
  .options-section {
    grid-template-columns: 1fr;
  }
  
  .download-btn {
    padding: 14px 24px;
    font-size: 16px;
  }
  
  .media-info {
    flex-direction: column;
    text-align: center;
  }
  
  .media-preview img {
    width: 100%;
    max-width: 200px;
  }
  
  .theme-toggle {
    top: 10px;
    right: 10px;
  }
  
  .theme-btn {
    padding: 8px 15px;
    font-size: 16px;
  }
}
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #764ba2;
  outline-offset: 2px;
}

/* Smooth transitions */
.progress-bar,
.spinner,
.spinner-small {
  will-change: transform;
}

/* Custom scrollbar for quality select */
.quality-selector select {
  scrollbar-width: thin;
  scrollbar-color: #764ba2 #f0f0f0;
}

.quality-selector select::-webkit-scrollbar {
  width: 8px;
}

.quality-selector select::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 4px;
}

.quality-selector select::-webkit-scrollbar-thumb {
  background: #764ba2;
  border-radius: 4px;
}

body.dark-mode .quality-selector select::-webkit-scrollbar-track {
  background: #2d2d44;
}

body.dark-mode .quality-selector select::-webkit-scrollbar-thumb {
  background: #a55eea;
}