:root {
  --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Premium HSL Color Palette */
  --bg-dark: hsl(222, 47%, 8%);
  --bg-card: hsla(223, 40%, 12%, 0.75);
  --bg-input: hsla(223, 40%, 8%, 0.6);
  --border-color: hsla(217, 30%, 22%, 0.6);
  --border-focus: hsla(214, 100%, 60%, 0.8);
  
  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(215, 20%, 65%);
  --text-dark: hsl(215, 20%, 50%);

  --primary: hsl(214, 100%, 54%);
  --primary-glow: hsla(214, 100%, 54%, 0.35);
  --secondary: hsl(262, 83%, 62%);
  --secondary-glow: hsla(262, 83%, 62%, 0.35);
  
  --accent-cyan: hsl(180, 100%, 50%);
  --accent-green: hsl(142, 72%, 49%);
  --accent-red: hsl(350, 89%, 60%);

  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 30px 0px hsla(214, 100%, 54%, 0.15);
}

/* Reset & Core Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Accents */
.background-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, var(--secondary-glow) 40%, transparent 70%);
  z-index: 1;
  pointer-events: none;
  filter: blur(80px);
}

/* Layout Container */
.app-container {
  width: 100%;
  max-width: 800px;
  padding: 2.5rem 1.5rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header Styles */
.app-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2.75rem;
  color: var(--primary);
  filter: drop-shadow(0 0 12px var(--primary-glow));
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-main) 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo h1 span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 500px;
  line-height: 1.5;
  font-weight: 400;
}

/* Main Card (Glassmorphic) */
.main-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2.25rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Input Section */
.input-section {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1.25rem;
  color: var(--text-dark);
  font-size: 1.2rem;
  pointer-events: none;
  transition: color 0.3s;
}

#video-url {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.15rem 3.5rem 1.15rem 3.25rem;
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

#video-url:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

#video-url:focus + .input-icon {
  color: var(--primary);
}

.clear-btn {
  position: absolute;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn:hover {
  color: var(--text-main);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  border-radius: 16px;
  padding: 0 2rem;
  color: white;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45), 0 0 15px var(--secondary-glow);
}

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

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 0;
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  position: relative;
}

.double-bounce1, .double-bounce2 {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--primary);
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
  background-color: var(--secondary);
  animation-delay: -1.0s;
}

@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0);
  } 50% { 
    transform: scale(1.0);
  }
}

.loading-state p {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.loading-hint {
  color: var(--text-dark);
  font-size: 0.85rem;
}

/* Error State */
.error-state {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--accent-red);
}

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

.error-state p {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Results Card */
.results-card {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  animation: fadeIn 0.5s ease;
}

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

.video-preview-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 1.75rem;
  align-items: flex-start;
}

.thumbnail-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border: 1px solid var(--border-color);
}

.thumbnail-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duration-badge {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.video-meta h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.uploader-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: hsla(217, 30%, 25%, 0.4);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.uploader-badge i {
  color: var(--primary);
}

.video-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Download Options Section */
.download-options-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.download-options-section h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.download-options-section h3 i {
  color: var(--accent-cyan);
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Format Card */
.format-card {
  background: hsla(223, 30%, 18%, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.format-card:hover {
  background: hsla(223, 30%, 22%, 0.6);
  border-color: var(--text-dark);
}

.format-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.quality-badge {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  min-width: 60px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  font-family: var(--font-display);
}

.format-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.format-res {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.format-ext {
  color: var(--text-dark);
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.btn-download {
  background: hsla(142, 72%, 49%, 0.15);
  color: var(--accent-green);
  border: 1px solid hsla(142, 72%, 49%, 0.3);
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-download:hover {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
  box-shadow: 0 4px 12px hsla(142, 72%, 49%, 0.3);
}

/* Download Overlay */
.download-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}

.download-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 3rem;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.download-spinner {
  font-size: 3.5rem;
  color: var(--accent-cyan);
  margin-bottom: 0.5rem;
}

.pulsing {
  animation: pulse-glow 1.5s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 5px rgba(6, 182, 212, 0.2));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 15px rgba(6, 182, 212, 0.6));
  }
}

.download-progress-card h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

#downloading-file-name {
  color: var(--text-muted);
  font-size: 0.95rem;
  word-break: break-all;
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.download-hint {
  color: var(--text-dark);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Footer */
.app-footer {
  text-align: center;
  color: var(--text-dark);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.footer-links span i {
  color: var(--primary);
}

/* Utility Helper */
.hidden {
  display: none !important;
}

/* Multi-Device Responsive Design */

/* 1. Tablet & Small Laptop (max-width: 900px) */
@media (max-width: 900px) {
  .app-container {
    padding: 2rem 1.25rem;
    gap: 1.5rem;
  }
  .logo h1 {
    font-size: 2.25rem;
  }
  .logo-icon {
    font-size: 2.25rem;
  }
  .tagline {
    font-size: 0.95rem;
    max-width: 420px;
  }
  .main-card {
    padding: 1.75rem;
    gap: 1.5rem;
  }
  .video-preview-grid {
    gap: 1.25rem;
  }
}

/* 2. Mobile & Smartphone (max-width: 650px) */
@media (max-width: 650px) {
  .video-preview-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .thumbnail-wrapper {
    max-width: 320px;
    margin: 0 auto; /* Center thumbnail on mobile */
  }
  .input-section {
    flex-direction: column;
    gap: 0.75rem;
  }
  .btn-primary {
    padding: 1.15rem 2rem;
    justify-content: center;
    width: 100%;
  }
  .app-container {
    padding: 1.5rem 1rem;
  }
  .main-card {
    padding: 1.5rem;
  }
  .format-card {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    text-align: center;
  }
  .format-info {
    flex-direction: column;
    gap: 0.5rem;
  }
  .btn-download {
    justify-content: center;
  }
}

/* 3. Small Mobile / Tiny Screens (max-width: 450px) */
@media (max-width: 450px) {
  .logo h1 {
    font-size: 1.85rem;
  }
  .logo-icon {
    font-size: 1.85rem;
  }
  .main-card {
    padding: 1.15rem;
    border-radius: 18px;
  }
  .video-meta h2 {
    font-size: 1.15rem;
  }
  .uploader-badge {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
  }
  .btn-quick-download {
    font-size: 0.95rem;
    padding: 0.95rem 1.25rem;
  }
  .download-progress-card {
    padding: 2rem 1.5rem;
  }
  .download-progress-card h3 {
    font-size: 1.35rem;
  }
}

/* 4. Large Screens / Ultra-wide monitors (> 1200px) */
@media (min-width: 1200px) {
  .app-container {
    max-width: 900px;
  }
  .background-glow {
    width: 800px;
    height: 800px;
  }
}

/* Quick Download button styling */
.quick-download-wrapper {
  margin-top: 0.75rem;
  width: 100%;
}

.btn-quick-download {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-green) 0%, hsl(160, 80%, 40%) 100%);
  border: none;
  border-radius: 14px;
  padding: 1.1rem 1.5rem;
  color: white;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-quick-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4), 0 0 15px rgba(16, 185, 129, 0.2);
}

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

.btn-quick-download i {
  font-size: 1.25rem;
}

/* Collapsible alternative formats styling */
.alternative-downloads-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.toggle-formats-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  width: fit-content;
  margin: 0 auto;
  transition: color 0.2s ease;
}

.toggle-formats-btn:hover {
  color: var(--text-main);
}

.toggle-icon {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-icon.rotated {
  transform: rotate(180deg);
}

.alternative-formats {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.alternative-formats.hidden {
  opacity: 0 !important;
  display: none !important;
}

/* Sponsored Link styling */
.sponsored-link {
  color: hsl(45, 95%, 55%) !important;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  border-bottom: 1px dashed transparent;
}

.sponsored-link:hover {
  color: hsl(45, 95%, 65%) !important;
  border-bottom: 1px dashed hsl(45, 95%, 65%);
}

.sponsored-link i {
  color: hsl(45, 95%, 55%);
}

/* Disclaimer Styling */
.disclaimer-container {
  margin-top: 1.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.disclaimer-text {
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
  opacity: 0.55;
  text-align: center;
  margin: 0;
}
