:root {
  --snap-yellow: #fffc00;
  --dark: #1a1a1d;
  --white: #ffffff;
  --cta-color: #ff6b6b;
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow-light: rgba(255, 252, 0, 0.2);
  --shadow-dark: rgba(26, 26, 29, 0.3);
  --muted: rgba(255, 255, 255, 0.7);
  --maxw: 1200px;
}

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

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(
    135deg,
    var(--dark) 0%,
    #2d2d35 50%,
    var(--dark) 100%
  );
  color: var(--white);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Effects */
body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
      circle at 25% 25%,
      rgba(255, 252, 0, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 75% 75%,
      rgba(255, 107, 107, 0.12) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 50% 10%,
      rgba(255, 107, 107, 0.08) 0%,
      transparent 60%
    );
  animation: bgGlow 15s ease-in-out infinite alternate;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
      45deg,
      transparent 48%,
      rgba(255, 252, 0, 0.02) 49%,
      rgba(255, 252, 0, 0.02) 51%,
      transparent 52%
    ),
    linear-gradient(
      -45deg,
      transparent 48%,
      rgba(255, 107, 107, 0.015) 49%,
      rgba(255, 107, 107, 0.015) 51%,
      transparent 52%
    );
  background-size: 100px 100px, 150px 150px;
  animation: gridMove 30s linear infinite;
  z-index: -1;
}

@keyframes bgGlow {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.1) rotate(3deg);
    opacity: 0.8;
  }
}

@keyframes gridMove {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(100px, 100px);
  }
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 20px;
  position: relative;
  z-index: 1;
}

/* Glass Card Component */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

section {
  padding: 1rem 0;
}

/* Header Section */
.tool-header {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  margin-top: 5rem;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.tool-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 252, 0, 0.1),
    transparent
  );
  animation: headerShine 4s ease-in-out infinite;
}

@keyframes headerShine {
  0%,
  100% {
    left: -100%;
  }
  50% {
    left: 100%;
  }
}

.tool-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  background: linear-gradient(45deg, var(--snap-yellow), var(--white));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* Search Form */
.search {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--white);
  padding: 1rem 1.5rem;
  border-radius: 50px;
  font-size: 1rem;
  min-width: 250px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.search input:focus {
  outline: none;
  border-color: var(--snap-yellow);
  box-shadow: 0 0 20px rgba(255, 252, 0, 0.3);
}

.search input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
.search .searchbtn{
  padding: 0.9rem 1.5rem;
}
/* .search .searchbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(90deg, var(--cta-color), #ff8a8a);
  color: #fff;
  border: none;
  padding: 0.78rem 1.6rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 10px 30px rgba(255, 107, 107, 0.16),
    inset 0 -3px 0 rgba(0,0,0,0.06);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 120ms ease;
  transform-origin: center;
} */

/* small left icon (emoji fallback) */
/* .search .searchbtn::before {
  content: "🔍";
  display: inline-block;
  transform: translateY(-1px);
  font-size: 1.05em;
  opacity: 0.95;
} */

/* hover / active / focus */
/* .search .searchbtn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 40px rgba(255, 107, 107, 0.18);
}
.search .searchbtn:active { transform: translateY(-1px) scale(0.995); }
.search .searchbtn:focus {
  outline: none;
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.12), 0 12px 30px rgba(255,107,107,0.12);
} */

/* make fetch button more compact on small screens */
/* @media (max-width: 520px) {
  .search .searchbtn { padding: 0.6rem 1rem; font-size: 0.95rem; border-radius: 12px; }
  .search .searchbtn::before { font-size: 0.98em; }
} */


/* Profile Section */
.profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  position: relative;
  overflow: hidden;
}

.profile::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 107, 107, 0.1),
    transparent
  );
  transition: left 0.8s ease;
}

.profile:hover::before {
  left: 100%;
}

.profile.hidden {
  display: none;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--snap-yellow);
  box-shadow: 0 8px 25px rgba(255, 252, 0, 0.3);
  transition: all 0.3s ease;
}

.profile:hover .avatar {
  transform: scale(1.1);
  box-shadow: 0 12px 35px rgba(255, 252, 0, 0.5);
}

.profile-info h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--snap-yellow);
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.profile-actions {
  margin-left: auto;
  display: flex;
  gap: 1rem;
}

/* Buttons */
.btn {
  background: linear-gradient(45deg, var(--cta-color), var(--cta-color));
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transition: all 0.6s ease;
  transform: translate(-50%, -50%);
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

.btn.ghost {
  background: transparent;
  border: 2px solid var(--glass-border);
  color: var(--white);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--snap-yellow);
  color: var(--snap-yellow);
  box-shadow: 0 8px 25px rgba(255, 252, 0, 0.2);
}

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

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

/* Status */
.status {
  margin: 1rem 0;
  color: var(--muted);
  text-align: center;
  font-size: 1rem;
}

/* Results Section */
.results {
  margin-top: 2rem;
}

.results.hidden {
  display: none;
}

/* Progress Area */
.progress-area {
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

.progress-area.hidden {
  display: none;
}

.progress-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--snap-yellow), var(--cta-color));
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(255, 252, 0, 0.5);
}

.progress-text {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.8rem;
  text-align: center;
  font-weight: 600;
}
/* small styles for in-button progress */
#downloadAllBtn .dl-state { font-weight: 600; }
#downloadAllBtn .dl-percent { opacity: 0.9; font-size: 0.9em; }


/* Media Grid */
.snap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.media-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.media-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 252, 0, 0.1),
    transparent
  );
  transition: left 0.6s ease;
}

.media-card:hover::before {
  left: 100%;
}

.media-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.media-content {
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
  position: relative;
}

.media-content img,
.media-content video {
  max-width: 100%;
  max-height: 250px;
  border-radius: 12px;
  display: block;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
}

.media-meta small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--dark);
  color: var(--white);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--glass-border);
}

.icon-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--snap-yellow);
  border-color: var(--snap-yellow);
}

/* JSON Area */
.json-area {
  margin-top: 2rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 15px;
  overflow: hidden;
}

.json-area summary {
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.json-area summary:hover {
  background: rgba(255, 252, 0, 0.1);
  color: var(--snap-yellow);
}

.snap-json {
  background: rgba(0, 0, 0, 0.3);
  color: #cfe8ff;
  padding: 1.5rem;
  margin: 0;
  max-height: 400px;
  overflow: auto;
  font-size: 0.8rem;
  font-family: "Courier New", monospace;
  line-height: 1.4;
}

/* Footer */
.foot {
  margin-top: 3rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem 15px;
  }

  .tool-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
    padding: 1rem;
  }

  .search {
    flex-direction: column;
    gap: 1rem;
  }

  .search input {
    min-width: 100%;
  }

  .profile {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
  }

  .profile-actions {
    width: 100%;
    justify-content: center;
    margin-left: 0;
    margin-top: 1rem;
  }

  .snap-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .media-meta {
    flex-wrap: wrap;
  }

  .profile-actions {
    flex-direction: column;
    gap: 0.8rem;
  }

  .controls {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .icon-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
}

/* ========= Snap loader ========= */
.status.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0.6rem 1rem;
}

.status .loader {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.status .loader .ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--snap-yellow);
  animation: snap-spin 1s linear infinite;
  box-shadow: 0 0 14px rgba(255, 252, 0, 0.12);
  flex: 0 0 auto;
}

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

.status .loader .dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-width: 64px;
}

.status .loader .dots span {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--snap-yellow), var(--cta-color));
  opacity: 0.95;
  transform: translateY(0);
  animation: snap-bounce 0.9s infinite ease-in-out;
}

.status .loader .dots span:nth-child(2) {
  animation-delay: 0.12s;
}
.status .loader .dots span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes snap-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.85;
  }
  40% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

.status .loader .label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
}

.sr-only {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* input group with inline actions (paste / clear) */
.input-group {
  position: relative;
  flex: 1 1 auto;
  max-width: 640px;
}
.input-group input {
  width: 100%;
  /* keep existing padding but add right padding for the inline buttons */
  padding-right: 128px; /* room for the two buttons */
  box-sizing: border-box;
}

/* action buttons container (positioned on the right inside the input) */
.input-actions { right: 5px; top: 50%; transform: translateY(-50%); gap: 8px; position: absolute; }

/* Paste button: subtle glass + CTA hover */
.inputbtns {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 0.7rem;
  border-radius: 10px 50px 50px 10px;
  /* font-weight: 600; */
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
  backdrop-filter: blur(6px);
}

/* change to CTA tint on hover to signal primary action */
.inputbtns:hover {
  background: linear-gradient(90deg, rgba(255,107,107,0.12), rgba(255,107,107,0.08));
  box-shadow: 0 12px 28px rgba(255,107,107,0.12);
  /* transform: translateY(-2px); */
  color: #fff;
}

/* Ensure inline buttons don't overlap input text on very small screens */
@media (max-width: 420px) {
  .input-group input { padding-right: 90px; }
  .inputbtns { font-size: 0.82rem; }
}