/* FluxSave – Dark glass UI */
:root {
  --bg-dark: #0a0a0f;
  --card-bg: rgba(20, 20, 30, 0.68);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary: #06b6d4;
  --secondary: #8b5cf6;
  --text-main: #ffffff;
  --text-dim: #94a3b8;
  --error: #ef4444;
}

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

html,
body {
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background */
.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  z-index: -2;
}

.bg-glow {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70vw;
  height: 70vw;
  background: radial-gradient(
    circle,
    rgba(139, 92, 246, 0.15) 0%,
    rgba(6, 182, 212, 0.06) 40%,
    transparent 70%
  );
  z-index: -1;
  pointer-events: none;
  filter: blur(20px);
}

/* Layout */
.page {
  width: 100%;
  max-width: 640px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
}

.brandDot {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--primary);
}

.brandText {
  display: flex;
  flex-direction: column;
}

.brandName {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.8px;
}

.brandSub {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Hero */
.hero {
  text-align: center;
  margin: 12px 0 8px;
}

.title {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: 900;
  line-height: 1.05;
  margin-bottom: 12px;
}

.grad {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.97rem;
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.cardTitle {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inputs & Buttons */
.input-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.input {
  flex: 1;
  min-width: 0;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #334155;
  color: white;
  font-size: 1rem;
  font-family: "Space Grotesk", sans-serif;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: white;
  border-radius: 12px;
  padding: 0 18px;
  cursor: pointer;
  transition: 0.2s;
  min-height: 54px;
  font-family: inherit;
  font-weight: 700;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cta,
.cta-alt {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  color: white;
  min-height: 54px;
}

.cta {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.cta-alt {
  background: #334155;
}

.cta:active,
.cta-alt:active,
.ghost:active,
.ghost-green:active,
.icon-btn:active {
  transform: scale(0.98);
}

.ghost,
.ghost-green {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s;
  min-height: 52px;
}

.ghost:hover {
  border-color: var(--secondary);
  color: white;
}

.ghost-green {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.ghost-green:hover {
  background: rgba(16, 185, 129, 0.1);
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
}

.downloadGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.downloadGroup {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.12);
}

.groupTitle {
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.groupTitle::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 12px;
  background: linear-gradient(
    90deg,
    rgba(6, 182, 212, 0.9),
    rgba(139, 92, 246, 0.35)
  );
  opacity: 0.55;
}

.formatGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.format-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
  color: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.format-btn:active {
  transform: scale(0.99);
}

.format-btn-primary {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.22), rgba(139, 92, 246, 0.18));
  border-color: rgba(6, 182, 212, 0.4);
}

.format-btn-primary .btn-quality-label {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.format-btn-primary:hover {
  border-color: rgba(6, 182, 212, 0.65);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(139, 92, 246, 0.24));
}

.format-btn-ad {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
}

.format-btn-ad .btn-quality-label {
  color: #d1fae5;
}

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

.mt-3 {
  margin-top: 15px;
}

.tiny {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.6;
}

.detect-text {
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 10px;
  min-height: 20px;
  font-weight: 600;
}

.error-text {
  font-size: 0.88rem;
  color: var(--error);
  margin-bottom: 10px;
  min-height: 20px;
}

/* Loader */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--primary);
  font-weight: 600;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(20, 22, 35, 0.97);
  color: #fff;
  padding: 13px 20px 13px 16px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255,255,255,0.05) inset;
  z-index: 1000;
  max-width: min(420px, 92vw);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.09);
  animation: toastSlideUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast--success {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(10, 30, 22, 0.97);
}

.toast.toast--error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(30, 10, 10, 0.97);
}

.toast.toast--info {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(8, 20, 30, 0.97);
}

.toast.toast--warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(28, 20, 8, 0.97);
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
}

.toast-body {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.toast-title {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 1px;
  color: #fff;
}

.toast-msg {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.72);
  font-weight: 500;
}

@keyframes toastSlideUp {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* How to Download Guide */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.guide-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  transition: border-color 0.2s, background 0.2s;
}

.guide-step:hover {
  border-color: rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.04);
}

.guide-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.9rem;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.3);
}

.guide-step-body {}

.guide-step-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: white;
  margin-bottom: 3px;
}

.guide-step-desc {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.guide-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.guide-platform-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.3px;
}

/* Media meta block */
.media-meta-block {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  background: rgba(0,0,0,0.18);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}

.meta-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

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

.meta-title {
  font-weight: 800;
  font-size: 1rem;
  color: white;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.meta-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}

/* Format quality cards */
.format-btn {
  width: 100%;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s ease, background 0.18s ease,
    border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
  min-height: 64px;
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
}

.btn-quality-label {
  font-size: 1rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

.btn-ext-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: var(--text-dim);
}

.btn-hd-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #34d399;
  background: rgba(52,211,153,0.12);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Spotify card */
.spotify-card {
  border-color: rgba(29,185,84,0.25) !important;
  background: rgba(16, 24, 20, 0.72) !important;
}

.spotify-icon {
  color: #1DB954;
  font-size: 1.2rem;
}

.spotify-search-btn {
  background: rgba(29,185,84,0.15) !important;
  border-color: rgba(29,185,84,0.35) !important;
  color: #1DB954 !important;
}

.spotify-search-btn:hover {
  background: rgba(29,185,84,0.25) !important;
}

.spinner-green {
  border-color: rgba(29,185,84,0.2) !important;
  border-top-color: #1DB954 !important;
}

/* Spotify search results */
.spotify-results {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spotify-track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.2);
  transition: border-color 0.2s, background 0.2s;
}

.spotify-track-item:hover {
  border-color: rgba(29,185,84,0.35);
  background: rgba(29,185,84,0.05);
}

.spotify-track-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

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

.spotify-track-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spotify-track-artist {
  font-size: 0.82rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spotify-track-duration {
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-right: 4px;
}

.spotify-dl-btn {
  background: linear-gradient(135deg, #1DB954, #17a845);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

.spotify-dl-btn:hover {
  opacity: 0.88;
}

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

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

/* Footer */
.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 10px 0 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

@media (max-width: 560px) {
  .page {
    padding-left: 12px;
    padding-right: 12px;
    gap: 14px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .btn-grid {
    grid-template-columns: 1fr;
  }

  /* Format grid: keep 2 cols but make buttons more compact */
  .formatGrid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .format-btn {
    min-height: 56px;
    padding: 10px 6px;
    border-radius: 12px;
  }

  .btn-quality-label {
    font-size: 0.88rem;
  }

  .btn-ext-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .btn-hd-badge {
    font-size: 0.58rem;
    top: 4px;
    right: 5px;
  }

  .downloadGroup {
    padding: 12px;
  }

  /* Media meta: smaller thumbnail on mobile */
  .meta-thumb {
    width: 60px;
    height: 60px;
  }

  .meta-title {
    font-size: 0.9rem;
  }

  .meta-sub {
    font-size: 0.78rem;
  }

  /* Spotify track item: stack on mobile */
  .spotify-track-item {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
  }

  .spotify-track-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
  }

  .spotify-track-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .spotify-track-title {
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .spotify-track-artist {
    white-space: normal;
    word-break: break-word;
  }

  .spotify-track-duration {
    display: none;
  }

  .spotify-dl-btn {
    width: 100%;
    padding: 9px 10px;
    font-size: 0.82rem;
  }
}

@media (max-width: 430px) {
  .mobile-stack {
    flex-direction: column;
  }

  .icon-btn {
    width: 100%;
  }

  .title {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 0.92rem;
  }

  /* Even more compact format buttons on very small screens */
  .formatGrid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .format-btn {
    min-height: 52px;
    padding: 8px 4px;
  }

  .btn-quality-label {
    font-size: 0.82rem;
  }
}
