:root {
  --bg:      #050608;
  --bg2:     #0a0e11;
  --bg3:     #0e141a;
  --bg4:     #131c23;
  --border:  #16242e;
  --border2: #21343f;
  --cyan:    #22d3ee;
  --lime:    #a3e635;
  --cyan-dim:#22d3ee1f;
  --grad:    linear-gradient(110deg, #22d3ee, #a3e635);
  --grad-rev:linear-gradient(110deg, #a3e635, #22d3ee);
  --text:    #d6f1f7;
  --muted:   #5e7c8a;
  --dim:     #314650;
  --green:   #a3e635;
  --red:     #ff5d6c;
  --mono:    'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* `hidden` must win over class display rules (e.g. .preview { display:grid }). */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Cyber grid + glow background ── */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 50% at 15% 0%,  #22d3ee18 0%, transparent 60%),
    radial-gradient(45% 45% at 95% 10%, #a3e63514 0%, transparent 60%),
    radial-gradient(60% 60% at 70% 100%,#22d3ee10 0%, transparent 65%),
    linear-gradient(#0b1218 1px, transparent 1px),
    linear-gradient(90deg, #0b1218 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 44px 44px, 44px 44px;
  background-position: 0 0, 0 0, 0 0, center, center;
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 90%);
          mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 90%);
}
/* faint moving scanline */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(#22d3ee00 0%, #22d3ee06 50%, #22d3ee00 100%);
  background-size: 100% 8px;
  animation: scan 8s linear infinite;
  opacity: .5;
}
@keyframes scan { from { background-position: 0 0; } to { background-position: 0 100%; } }

/* ── Header ── */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 5vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; font-family: var(--mono); letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--grad);
  color: #04110f;
  box-shadow: 0 0 18px #22d3ee66, inset 0 0 0 1px #ffffff22;
  font-size: 1rem;
}
.brand-dim { color: var(--muted); font-weight: 500; }
.brand-dim::before { content: "_"; color: var(--cyan); }
.api-link {
  color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 500;
  font-family: var(--mono);
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px;
  transition: .2s;
}
.api-link:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px #22d3ee2e; }

/* ── Layout ── */
.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 64px) clamp(16px, 5vw, 24px) 64px;
  flex: 1;
}

/* ── Hero ── */
.hero { text-align: center; }
.hero h1 {
  font-size: clamp(1.9rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px #22d3ee44;
}
.sub {
  color: var(--muted);
  max-width: 540px;
  margin: 18px auto 0;
  font-size: clamp(.95rem, 2.5vw, 1.05rem);
}

/* ── Search bar ── */
.search {
  margin: 32px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #070c0fcc;
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px #00000040, 0 18px 50px #0009;
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 26px #22d3ee3a, 0 18px 50px #0009;
}
.search-icon { font-size: 1.2rem; flex-shrink: 0; line-height: 1; filter: drop-shadow(0 0 6px #22d3ee66); }
#url {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--mono);
  padding: 10px 4px;
}
#url::placeholder { color: var(--dim); }
.ghost-btn {
  background: var(--bg4);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: .8rem;
  font-weight: 600;
  font-family: var(--mono);
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
}
.ghost-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.cta-btn {
  background: var(--grad);
  color: #04110f;
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  font-size: .9rem;
  font-weight: 800;
  font-family: var(--mono);
  letter-spacing: .02em;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 0 22px #22d3ee55;
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.cta-btn:hover { transform: translateY(-1px); box-shadow: 0 0 30px #a3e63577; filter: brightness(1.08); }
.cta-btn:active { transform: translateY(0); }
.cta-btn:disabled { opacity: .9; cursor: progress; transform: none; }
.cta-btn .spinner { width: 15px; height: 15px; border-width: 2px; border-color: #04110f3d; border-top-color: #04110f; }

/* ── Platform badges ── */
.platforms {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 500;
  font-family: var(--mono);
  transition: .2s;
}
.pill::before { content: "#"; color: var(--dim); }
.pill.active { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-dim); box-shadow: 0 0 16px #22d3ee2e; }
.pill.active::before { color: var(--cyan); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }
.pill.active .dot { background: var(--lime); opacity: 1; box-shadow: 0 0 8px var(--lime); }

/* ── Empty state (shown before the first search) ── */
.empty {
  margin-top: 40px;
  border: 1px dashed var(--border2);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  background: repeating-linear-gradient(45deg, #ffffff00 0 10px, #ffffff03 10px 20px);
}
.empty-icon {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--cyan);
  filter: drop-shadow(0 0 14px #22d3ee66);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.empty-title {
  margin-top: 14px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
.empty-sub {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  letter-spacing: .02em;
}
.empty-sub::before { content: "// "; color: var(--lime); }

/* ── Status / errors ── */
.status {
  margin-top: 26px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  font-size: .9rem;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 12px;
}
.status.error { border-color: #ff5d6c55; background: #ff5d6c0f; color: #ff9aa4; }
.status.loading { color: var(--muted); }
.spinner {
  width: 18px; height: 18px; flex-shrink: 0;
  display: inline-block;
  border: 2px solid var(--border2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  box-sizing: border-box;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ── */
.card {
  margin-top: 22px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 60px #0008;
  animation: rise .35s ease both;
}
/* neon top edge */
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--grad);
  opacity: .8;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Preview ── */
.preview { display: grid; grid-template-columns: 200px 1fr; }
.preview-thumb { position: relative; background: var(--bg4); aspect-ratio: 1; }
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-badge {
  position: absolute; top: 10px; left: 10px;
  background: #04110fcc; backdrop-filter: blur(6px);
  color: var(--cyan); font-size: .68rem; font-weight: 600;
  font-family: var(--mono);
  padding: 5px 10px; border-radius: 7px;
  border: 1px solid #22d3ee44;
}
.preview-body { padding: 20px 22px; min-width: 0; }
.pv-site { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; margin-bottom: 8px; font-family: var(--mono); }
.pv-site img { width: 16px; height: 16px; border-radius: 4px; }
.preview-body h2 {
  font-size: 1.1rem; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.preview-body p {
  color: var(--muted); font-size: .9rem; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pv-url {
  display: inline-block; margin-top: 12px;
  color: var(--cyan); font-size: .78rem; text-decoration: none;
  font-family: var(--mono);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pv-url:hover { text-decoration: underline; text-shadow: 0 0 12px #22d3ee66; }

/* ── Results ── */
.results { padding: 20px 22px; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.results-head h3 { font-size: 1rem; font-weight: 700; font-family: var(--mono); }
.source-tag {
  font-family: var(--mono);
  font-size: .7rem; color: var(--lime);
  background: #a3e6350f; border: 1px solid #a3e63533;
  padding: 4px 10px; border-radius: 7px;
}
.media-grid { display: grid; gap: 10px; }
.yt-group {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--cyan); margin: 6px 2px 2px; font-family: var(--mono);
}
.yt-group:first-child { margin-top: 0; }
.dl-btn .spinner { width: 14px; height: 14px; border-width: 2px; border-color: #04110f44; border-top-color: #04110f; }
.media-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.media-row:hover { border-color: var(--border2); background: var(--bg4); box-shadow: 0 0 18px #22d3ee14; }
.mtype {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 9px; font-size: 1.1rem;
  background: #22d3ee14; border: 1px solid #22d3ee33;
}
.mtype.audio { background: #a3e63514; border-color: #a3e63533; }
.mtype.image { background: #a3e63514; border-color: #a3e63533; }
.minfo { flex: 1; min-width: 0; }
.minfo .mlabel { font-weight: 700; font-size: .92rem; font-family: var(--mono); }
.minfo .mmeta { color: var(--muted); font-size: .74rem; margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; font-family: var(--mono); }
.dl-btn {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--grad); color: #04110f;
  border: none; border-radius: 9px;
  padding: 9px 16px; font-size: .82rem; font-weight: 800;
  font-family: var(--mono);
  text-decoration: none; cursor: pointer;
  transition: transform .12s, box-shadow .2s, filter .2s;
  box-shadow: 0 0 16px #22d3ee3a;
}
.dl-btn:hover { transform: translateY(-1px); box-shadow: 0 0 24px #a3e63566; filter: brightness(1.08); }
.dl-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; filter: grayscale(.4); }

.attempts {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px dashed var(--border2);
  font-size: .76rem; color: var(--dim);
  font-family: var(--mono);
}
.attempts b { color: var(--muted); font-weight: 500; }

/* ── Footer ── */
.site-footer {
  position: relative; z-index: 1;
  text-align: center; padding: 24px 16px;
  color: var(--dim); font-size: .82rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ── */
@media (max-width: 560px) {
  .search { flex-wrap: wrap; }
  #url { flex: 1 1 100%; order: -1; }
  .cta-btn { flex: 1; }
  .preview { grid-template-columns: 1fr; }
  .preview-thumb { aspect-ratio: 16/9; }
  .api-link { display: none; }
}
