/* ========================================
   YT Downloader Pro — Design System
   Refined Dark Mode · WCAG Accessible
   ======================================== */

/* Design Tokens & Theme Variables */
:root {
  /* Layered dark surfaces (warm charcoal, not cold navy) */
  --bg-primary: #111113;
  --bg-surface: rgba(24, 24, 28, 0.85);
  --bg-card: rgba(32, 32, 38, 0.6);
  --bg-elevated: rgba(42, 42, 50, 0.55);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-hover: rgba(255, 255, 255, 0.14);
  --border-color-focus: rgba(99, 102, 241, 0.6);
  
  /* High-contrast text (passes WCAG 4.5:1 on all surfaces) */
  --text-primary: #e8e8ed;
  --text-secondary: #9498a8;
  --text-muted: #5c5f6e;
  
  /* Accent gradient: cool indigo → vibrant cyan (modern, unique) */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --primary-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #0891b2 100%);
  --primary-glow: rgba(99, 102, 241, 0.3);
  --primary-glow-intense: rgba(99, 102, 241, 0.5);
  
  /* Accent colors */
  --accent-purple: #818cf8;
  --accent-pink: #f472b6;
  --accent-blue: #60a5fa;
  --accent-cyan: #22d3ee;
  
  /* Status colors */
  --color-success: #34d399;
  --color-success-glow: rgba(52, 211, 153, 0.2);
  --color-danger: #f87171;
  --color-warning: #fbbf24;
  
  /* Radii */
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --radius-pill: 100px;
  
  /* Smooth 60fps / 120Hz Easing Physics */
  --transition-fast: 0.15s cubic-bezier(0.05, 0.7, 0.1, 1);
  --transition-normal: 0.28s cubic-bezier(0.05, 0.7, 0.1, 1);
  --transition-spring: 0.38s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition-smooth: 0.45s cubic-bezier(0.05, 0.7, 0.1, 1);
  
  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1.25rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
}

/* GPU Hardware Acceleration for Ultra-Smooth 60fps/120Hz Rendering */
.glass, .card, .btn, .quality-pill, .nav-item, .mobile-bottom-nav, .progress-bar-fill {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Noise Texture Overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* Background Ambient Glows */
.glow-bg {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(160px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  transition: opacity 1s ease;
}

.glow-purple {
  background: radial-gradient(circle, var(--accent-purple), transparent 70%);
  top: -15%;
  left: -10%;
  animation: glow-drift 20s ease-in-out infinite alternate;
}

.glow-pink {
  background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: glow-drift 25s ease-in-out infinite alternate-reverse;
}

@keyframes glow-drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -20px) scale(1.1); }
  100% { transform: translate(-20px, 30px) scale(0.95); }
}

/* Typography */
h1, h2, h3, h4, .app-logo {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

p {
  font-size: 0.925rem;
  line-height: 1.6;
}

.text-secondary {
  color: var(--text-secondary);
}

.accent-text {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Glassmorphism Panel Container */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(28px) saturate(1.3);
  -webkit-backdrop-filter: blur(28px) saturate(1.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  position: relative;
}

/* Subtle top-edge light reflection on glass panels */
.glass::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
  z-index: 1;
}

.card {
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  animation: card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-subtitle {
  margin-bottom: 1.5rem;
}

/* Setup Container */
.setup-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  width: 100%;
  max-width: 500px;
  position: relative;
  z-index: 10;
}



.setup-card {
  width: 100%;
  text-align: center;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Auth Lock Card & Form */
.auth-card {
  max-width: 440px;
  animation: authCardSlideIn 0.5s ease-out;
}

@keyframes authCardSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-shield-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.25));
  border: 2px solid rgba(99, 102, 241, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--accent-cyan);
  margin: 0.5rem 0;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.3), 0 0 60px rgba(6, 182, 212, 0.1);
  animation: shieldPulse 2.5s ease-in-out infinite;
}

@keyframes shieldPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(99, 102, 241, 0.3), 0 0 60px rgba(6, 182, 212, 0.1); }
  50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.5), 0 0 80px rgba(6, 182, 212, 0.2); }
}

#auth-title {
  font-size: 1.4rem;
  margin-top: 0.25rem;
}

#auth-subtitle {
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-input-wrapper input {
  width: 100%;
  padding: 0.9rem 2.8rem 0.9rem 2.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-input-wrapper input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.auth-input-wrapper input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.auth-input-wrapper .input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.toggle-pwd-btn {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.toggle-pwd-btn:hover {
  color: var(--text-primary);
}

.auth-error-banner {
  margin-top: 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  animation: authErrorShake 0.35s ease-out;
}

@keyframes authErrorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
}

/* Header Action Buttons */
.header-auth-badge {
  display: flex;
  align-items: center;
}

.header-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
}

.header-action-btn:hover {
  background: rgba(248, 113, 113, 0.15);
  color: var(--color-danger);
  border-color: rgba(248, 113, 113, 0.4);
}

.header-action-btn i {
  font-size: 0.85rem;
}

/* Double Bounce Spinner */
.spinner-container {
  width: 50px;
  height: 50px;
  position: relative;
  margin: 1rem 0;
}

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

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

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

/* Main Layout Grid */
.main-layout {
  width: 100%;
  max-width: 920px;
  position: relative;
  z-index: 2;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.25rem;
  margin-bottom: 1.25rem;
}

.app-logo {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  user-select: none;
}

.logo-icon {
  color: #ef4444;
  font-size: 1.75rem;
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.4));
}

.app-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 12px var(--primary-glow);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.header-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.header-tag:hover {
  color: var(--text-secondary);
  border-color: var(--border-color-hover);
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 18px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--primary-glow-intense);
}

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

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-danger);
  transform: translateY(-1px);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: transparent;
  color: var(--accent-purple);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.btn-link:hover {
  color: var(--accent-pink);
  text-decoration: underline;
}

/* ===== Search Input Area ===== */
.search-card h2 {
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-form {
  margin-top: 0.75rem;
}

.input-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.3rem;
  position: relative;
  transition: all var(--transition-normal);
  gap: 0.25rem;
}

.input-group:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12), 0 0 20px rgba(99, 102, 241, 0.1);
}

.input-icon {
  display: flex;
  align-items: center;
  padding-left: 1rem;
  padding-right: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.input-group:focus-within .input-icon {
  color: var(--accent-purple);
}

.input-group input[type="url"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.75rem 0.25rem;
  outline: none;
  min-width: 0;
}

.input-group input[type="url"]::placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.input-group .btn {
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.error-msg {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ===== Details Card ===== */
.details-card {
  animation-delay: 0.1s;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 2rem;
  align-items: start;
}

.video-preview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  width: 100%;
}

.thumbnail-wrapper {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.thumbnail-wrapper:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.thumbnail-blur-bg {
  position: absolute;
  inset: -16px;
  background-size: cover;
  background-position: center;
  filter: blur(24px) brightness(0.4) saturate(1.3);
  transform: scale(1.2);
  z-index: 0;
  pointer-events: none;
}

.thumbnail-wrapper img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.duration-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-display);
  z-index: 2;
  letter-spacing: 0.03em;
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

#video-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.channel-verify {
  color: var(--accent-blue);
  font-size: 0.78rem;
  margin-right: 0.2rem;
}

.stat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.stat-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all var(--transition-fast);
}

.stat-badge:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-hover);
}

/* ===== Download Settings Form ===== */
.download-settings {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
  width: 100%;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.settings-group > label:first-child {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.01em;
}

/* Radio Toggles */
.radio-toggle-group {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  width: 100%;
  min-width: 0;
}

.radio-toggle-group input[type="radio"] {
  display: none;
}

.radio-toggle-group label {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
  color: var(--text-muted);
}

.radio-toggle-group label:hover {
  color: var(--text-secondary);
}

.radio-toggle-group input[type="radio"]:checked + label {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.15);
}

/* Custom Select Dropdown */
.custom-select {
  width: 100%;
  min-width: 0;
  background-color: rgba(0, 0, 0, 0.35);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 2.25rem 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.custom-select option {
  background-color: #16161a;
  color: var(--text-primary);
}

/* Directory Selector */
.directory-selector {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.directory-selector input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
  text-overflow: ellipsis;
  transition: border-color var(--transition-fast);
}

.directory-selector input:focus {
  border-color: var(--accent-purple);
}

.directory-selector .btn {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
}

/* ===== Progress Layout ===== */
.progress-card {
  animation-delay: 0.15s;
}

.progress-ring-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.progress-ring-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-percent-text {
  position: absolute;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
}

.progress-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Progress Bars */
.progress-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 4px;
  width: 0;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* Animated shimmer on progress fill */
.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.animated-stripe {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.1) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.1) 75%,
    transparent 75%,
    transparent
  );
  background-size: 30px 30px;
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  0% { background-position: 30px 0; }
  100% { background-position: 0 0; }
}

.percent-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 40px;
  text-align: right;
}

.progress-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.stat-box:hover {
  border-color: var(--border-color-hover);
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Success Card ===== */
.success-card {
  text-align: center;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.success-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-success-glow);
  color: var(--color-success);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 0 30px var(--color-success-glow);
}

.success-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 480px;
  flex-wrap: wrap;
  justify-content: center;
}

.success-actions .btn {
  flex: 1;
  min-width: 130px;
}

/* ===== History Card ===== */
.history-card {
  animation-delay: 0.2s;
}

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

.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.history-empty-state i {
  font-size: 2.5rem;
  opacity: 0.4;
}

.history-empty-state p {
  font-size: 0.875rem;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color-hover);
  transform: translateX(3px);
}

.history-item-details {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.history-item-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.icon-video {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-purple);
}

.icon-audio {
  background: rgba(236, 72, 153, 0.12);
  color: var(--accent-pink);
}

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

.history-item-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3;
}

.history-item-path {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.history-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-item-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  transform: scale(1.1);
}

.history-item-btn.btn-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
}

/* ===== Anti-Algorithm Toggle Switch Box ===== */
.toggle-option-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-option-box:hover {
  border-color: var(--border-color-hover);
  background: rgba(0, 0, 0, 0.4);
}

.toggle-option-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.toggle-option-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toggle-option-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.toggle-input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  position: relative;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: white;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-input:checked + .toggle-slider {
  background: var(--primary-gradient);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.toggle-input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ===== Paste Button ===== */
.btn-paste {
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  border-radius: var(--radius-md);
  white-space: nowrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.btn-paste:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: white;
  transform: translateY(-1px);
}

/* ===== Anti-Algorithm Shield Badge ===== */
.shield-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2);
  animation: shield-pulse 3s ease-in-out infinite;
}

@keyframes shield-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2); }
  50% { box-shadow: 0 4px 24px rgba(16, 185, 129, 0.35); }
}

/* ===== Interactive Quality Pills ===== */
.quality-pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.quality-pill {
  flex: 1;
  min-width: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
  text-align: center;
}

.quality-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.quality-pill.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: translateY(-1px);
}

.quality-pill-hd {
  font-size: 0.62rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ===== Animations ===== */
.animate-pulse {
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.animate-scale {
  animation: pop-scale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes pop-scale {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

/* Setup Progress Layout */
.setup-progress-bar-container {
  width: 100%;
  max-width: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Desktop Input Wrappers */
.input-field-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.input-actions-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Bottom Nav Bar Hidden on Desktop */
.mobile-bottom-nav {
  display: none;
}

/* ===== Responsive Mobile Styles (Strictly for mobile screens) ===== */
@media (max-width: 768px) {
  .details-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .success-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .success-actions .btn {
    min-width: unset;
  }

  .progress-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .stat-box {
    padding: 0.65rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .progress-ring-header {
    gap: 0.75rem;
  }
}

/* Native Android Material 3 Layout (Phone Screen <= 600px) */
@media (max-width: 600px) {
  body {
    padding: 0 0 76px 0;
  }

  .main-layout {
    padding: 0.75rem;
    max-width: 100%;
  }

  .card {
    border-radius: 24px;
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
  }

  .app-header {
    padding: 0.85rem 0.5rem;
    margin-bottom: 0.75rem;
  }

  .input-group {
    flex-direction: column;
    background: transparent;
    border: none;
    padding: 0;
    gap: 0.75rem;
    box-shadow: none;
  }

  .input-field-wrapper {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.2rem 0.5rem;
    min-height: 52px;
  }

  .input-actions-row {
    width: 100%;
    display: flex;
    gap: 0.6rem;
  }

  .input-actions-row .btn {
    flex: 1;
    height: 48px;
    border-radius: 14px;
    font-size: 0.9rem;
  }

  #analyze-btn {
    flex: 1.3;
  }

  /* Hide History card on main Downloader screen (Mobile tab mode) */
  #history-panel {
    display: none;
  }

  .quality-pill {
    min-width: 75px;
    padding: 0.6rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Native Material 3 Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: rgba(17, 17, 19, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    z-index: 100;
  }

  .nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .nav-icon-wrapper {
    width: 52px;
    height: 30px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: all var(--transition-fast);
  }

  .nav-item.active {
    color: var(--accent-purple);
  }

  .nav-item.active .nav-icon-wrapper {
    background: rgba(99, 102, 241, 0.2);
    color: white;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== Selection ===== */
::selection {
  background: rgba(99, 102, 241, 0.3);
  color: white;
}
