/* ============================================
   APK Downloader — Custom Styles
   Layered on top of Tailwind CSS v3
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Dark theme (default) */
  --bg-primary: #0a0a12;
  --bg-secondary: #10101c;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-card-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
  --accent-gradient-reverse: linear-gradient(135deg, #06b6d4, #3b82f6);
  --success: #10b981;
  --success-hover: #059669;
  --error: #ef4444;
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.15);
  --navbar-blur: 16px;
  --transition-speed: 0.3s;
}

.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --border-card: rgba(0, 0, 0, 0.08);
  --border-card-hover: rgba(0, 0, 0, 0.15);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.1);
}

/* ---------- Base Resets ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  transition: background-color var(--transition-speed) ease,
              color var(--transition-speed) ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.5);
}

/* ---------- Animated Gradient Mesh Background (Hero) ---------- */
.hero-gradient-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.hero-gradient-bg::before {
  content: '';
  position: absolute;
  width: 150%;
  height: 150%;
  top: -25%;
  left: -25%;
  background:
    radial-gradient(ellipse 600px 600px at 20% 30%, rgba(59, 130, 246, 0.15) 0%, transparent 70%),
    radial-gradient(ellipse 500px 500px at 70% 20%, rgba(6, 182, 212, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 700px 700px at 50% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 70%),
    radial-gradient(ellipse 400px 400px at 80% 70%, rgba(14, 165, 233, 0.08) 0%, transparent 70%);
  animation: gradientShift 15s ease-in-out infinite alternate;
}

@keyframes gradientShift {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(30px, -20px) rotate(1deg);
  }
  66% {
    transform: translate(-20px, 15px) rotate(-1deg);
  }
  100% {
    transform: translate(10px, -10px) rotate(0.5deg);
  }
}

/* Noise texture overlay for hero */
.hero-gradient-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Floating Particles ---------- */
.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  animation: floatParticle linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-duration: 20s; animation-delay: 0s; width: 3px; height: 3px; }
.particle:nth-child(2) { left: 25%; animation-duration: 25s; animation-delay: -5s; width: 5px; height: 5px; background: rgba(6, 182, 212, 0.2); }
.particle:nth-child(3) { left: 40%; animation-duration: 18s; animation-delay: -3s; }
.particle:nth-child(4) { left: 55%; animation-duration: 22s; animation-delay: -8s; width: 6px; height: 6px; background: rgba(99, 102, 241, 0.2); }
.particle:nth-child(5) { left: 70%; animation-duration: 28s; animation-delay: -12s; width: 3px; height: 3px; }
.particle:nth-child(6) { left: 85%; animation-duration: 19s; animation-delay: -6s; background: rgba(6, 182, 212, 0.25); }
.particle:nth-child(7) { left: 15%; animation-duration: 24s; animation-delay: -10s; width: 5px; height: 5px; }
.particle:nth-child(8) { left: 60%; animation-duration: 21s; animation-delay: -4s; width: 3px; height: 3px; background: rgba(99, 102, 241, 0.15); }

@keyframes floatParticle {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(1);
    opacity: 0;
  }
}

/* ---------- Glassmorphism ---------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  transition: all var(--transition-speed) ease;
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-glow);
}

.glass-nav {
  background: rgba(10, 10, 18, 0.75);
  backdrop-filter: blur(var(--navbar-blur));
  -webkit-backdrop-filter: blur(var(--navbar-blur));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.light .glass-nav {
  background: rgba(248, 250, 252, 0.8);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.glass-search {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(59, 130, 246, 0.05);
}

.light .glass-search {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 0 40px rgba(59, 130, 246, 0.05);
}

/* ---------- Glow Effects ---------- */
.glow-border {
  position: relative;
  overflow: hidden;
}

.glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0), rgba(6, 182, 212, 0));
  z-index: -1;
  transition: background var(--transition-speed) ease;
}

.glow-border:hover::before {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(6, 182, 212, 0.3));
}

.glow-button {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

.glow-button::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.glow-button:hover::after {
  opacity: 1;
}

.glow-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* Pulsing glow on primary CTA */
.pulse-glow {
  animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2), 0 0 30px rgba(59, 130, 246, 0.1);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 0 50px rgba(59, 130, 246, 0.2);
  }
}

/* ---------- Scroll Reveal Animations ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }
.reveal-delay-6 { transition-delay: 0.6s; }

/* ---------- Feature Cards ---------- */
.feature-card {
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transition: transform 0.4s ease;
}

.feature-card:hover::before {
  transform: scaleX(1);
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-glow);
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: white;
  flex-shrink: 0;
  transition: transform var(--transition-speed) ease;
}

.feature-card:hover .feature-icon {
  transform: scale(1.1);
}

/* ---------- How It Works Steps ---------- */
.step-connector {
  position: relative;
}

.step-connector::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.4), rgba(6, 182, 212, 0.4));
  background-size: 8px 2px;
  background-repeat: repeat-x;
  transform: translateY(-50%);
}

@media (max-width: 768px) {
  .step-connector::after {
    top: 100%;
    left: 50%;
    width: 2px;
    height: 40px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.4), rgba(6, 182, 212, 0.4));
    background-size: 2px 8px;
    background-repeat: repeat-y;
    transform: translateX(-50%);
  }
}

.step-number {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
  background: var(--accent-gradient);
  color: white;
  position: relative;
  z-index: 2;
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.step-number:hover {
  transform: scale(1.15);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.4);
}

/* ---------- FAQ Accordion ---------- */
.faq-item {
  border-bottom: 1px solid var(--border-card);
  overflow: hidden;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition-speed) ease;
}

.faq-question:hover {
  color: var(--accent-blue);
}

.faq-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
}

.faq-item.active .faq-chevron {
  transform: rotate(180deg);
  color: var(--accent-blue);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
}

.faq-item.active .faq-answer {
  max-height: 300px;
  padding-bottom: 1.25rem;
}

.faq-answer-text {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.95rem;
}

/* ---------- Search Input Styles ---------- */
.search-input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-speed) ease;
}

.light .search-input {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-input:focus::placeholder {
  opacity: 0.6;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--accent-gradient);
  color: #fff;
  transition: all var(--transition-speed) ease;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
}

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

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

.btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--success), #047857);
  color: #fff;
  transition: all var(--transition-speed) ease;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35);
}

.btn-success:active {
  transform: scale(0.98);
}

/* ---------- App Result Card ---------- */
.app-result {
  display: none;
  animation: slideDown 0.4s ease forwards;
}

.app-result.visible {
  display: block;
}

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

.app-icon {
  width: 80px;
  height: 80px;
  border-radius: 20%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (min-width: 640px) {
  .app-icon-lg {
    width: 140px;
    height: 140px;
  }
}

.info-grid-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: white;
  flex-shrink: 0;
}

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ---------- Language Dropdown ---------- */
.lang-dropdown {
  position: relative;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
}

.light .lang-dropdown-menu {
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.lang-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  text-align: left;
}

.lang-option:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
}

.lang-option.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  font-weight: 500;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  color: var(--text-secondary);
}

.light .theme-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.theme-toggle:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover svg {
  transform: rotate(20deg);
}

/* ---------- Mobile Menu ---------- */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-card);
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.75rem 1rem;
    border-radius: 8px;
  }

  .nav-links a:hover {
    background: rgba(59, 130, 246, 0.1);
  }
}

/* ---------- Prose Content ---------- */
.prose-content h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.prose-content h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.prose-content p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* ---------- Gradient Text ---------- */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Divider ---------- */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border-card);
  margin: 0;
  border: none;
}

/* ---------- Error Text ---------- */
.error-text {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
}

.error-text.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ---------- RTL Overrides ---------- */
[dir="rtl"] .faq-question {
  text-align: right;
}

[dir="rtl"] .faq-chevron {
  transform: scaleX(-1);
}

[dir="rtl"] .faq-item.active .faq-chevron {
  transform: scaleX(-1) rotate(180deg);
}

[dir="rtl"] .step-connector::after {
  left: auto;
  right: 100%;
}

[dir="rtl"] .lang-dropdown-menu {
  right: auto;
  left: 0;
}

[dir="rtl"] .search-input {
  text-align: right;
}

[dir="rtl"] .search-input::placeholder {
  text-align: right;
}

[dir="rtl"] .nav-links {
  direction: rtl;
}

/* ---------- Selection Color ---------- */
::selection {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ---------- Download Sources Grid ---------- */
.download-sources-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
  animation: slideDown 0.4s ease forwards;
}

@media (min-width: 640px) {
  .download-sources-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.download-sources-title {
  grid-column: 1 / -1;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.source-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  font-family: var(--font-body);
  width: 100%;
  text-align: left;
  color: var(--text-primary);
}

.light .source-btn {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

.source-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--source-color, var(--accent-blue));
  transition: width 0.25s ease;
}

[dir="rtl"] .source-btn::before {
  left: auto;
  right: 0;
  border-radius: 0 3px 3px 0;
}

.source-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.light .source-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.source-btn:hover:not(:disabled)::before {
  width: 4px;
}

.source-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.source-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.source-btn .source-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.25s ease;
}

.light .source-btn .source-icon {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.06);
}

.source-btn:hover:not(:disabled) .source-icon {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

.source-btn .source-text {
  flex: 1;
  min-width: 0;
}

.source-btn .source-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.source-btn .source-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.source-tag--direct {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.source-tag--available {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.source-tag--unavailable {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
}

.source-tag--loading {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.source-btn .source-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.25s ease, color 0.25s ease;
}

.source-btn:hover:not(:disabled) .source-arrow {
  color: var(--text-primary);
  transform: translateX(2px);
}

[dir="rtl"] .source-btn:hover:not(:disabled) .source-arrow {
  transform: translateX(-2px) scaleX(-1);
}

[dir="rtl"] .source-btn .source-arrow {
  transform: scaleX(-1);
}

/* Source skeleton loading */
.source-btn--loading {
  pointer-events: none;
}

.source-btn--loading .source-icon,
.source-btn--loading .source-name,
.source-btn--loading .source-meta {
  position: relative;
  overflow: hidden;
}

.source-btn--loading .source-name::after,
.source-btn--loading .source-meta::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  animation: shimmer 1.5s infinite;
}

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

/* Download all button (spans full width) */
.download-all-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
}

.download-all-divider::before,
.download-all-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-card);
}

.download-all-divider span {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ---------- Transition Classes ---------- */
.transition-theme {
  transition: background-color var(--transition-speed) ease,
              color var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
}

/* ---------- Search Dropdown (Phase 2) ---------- */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 100;
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
  animation: dropdownSlide 0.2s ease;
}

.light .search-dropdown {
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

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

.search-dropdown-loading,
.search-dropdown-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.75rem;
  border: none;
  background: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s ease;
  text-align: left;
}

.search-result-item:hover {
  background: rgba(59, 130, 246, 0.08);
}

.search-result-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.search-result-icon--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
}

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

.search-result-title {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-pkg {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- App Metadata Card (Phase 3) ---------- */
.app-meta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: slideDown 0.4s ease forwards;
}

.app-meta-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.app-meta-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.app-meta-icon--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 1px solid var(--border-card);
}

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

.app-meta-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.125rem 0;
  color: var(--text-primary);
}

.app-meta-developer {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.app-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.app-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.light .app-meta-badge {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.app-meta-badge--rating {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.2);
}

.light .app-meta-badge--rating {
  background: rgba(234, 179, 8, 0.1);
  color: #d97706;
  border-color: rgba(234, 179, 8, 0.2);
}

.app-meta-badge--category {
  background: rgba(45, 212, 191, 0.1);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.2);
}

.light .app-meta-badge--category {
  background: rgba(20, 184, 166, 0.08);
  color: #0d9488;
  border-color: rgba(20, 184, 166, 0.2);
}

.app-meta-desc {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border-card);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.app-meta-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.2s ease;
}

.app-meta-link:hover {
  color: var(--accent-cyan);
}

@media (max-width: 480px) {
  .app-meta-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .app-meta-badges {
    justify-content: center;
  }
}

