:root {
  --bg: #0e0e10;
  --fg: #f5f5f7;
  --muted: #9aa0a6;
  --card: #1a1a1d;
  --accent: #fc009a;
  --radius: 12px;
}

* { box-sizing: border-box; }

html {
  background-color: var(--bg);
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--fg);
  font-family: 'Mozilla Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  overflow-x: hidden;
  background: transparent;
}

/* Page wrappers must establish their own stacking context above the smoke pseudo-elements */
.page-search, .page-login { position: relative; z-index: 1; }

/* Pink smoke layer 1 — slow rotation, brighter blobs */
body::before {
  content: '';
  position: fixed;
  inset: -40%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(252, 0, 154, 0.45) 0%, transparent 35%),
    radial-gradient(circle at 70% 65%, rgba(252, 0, 154, 0.35) 0%, transparent 40%);
  animation: smokeRotate 60s linear infinite;
  will-change: transform;
  filter: blur(60px);
}

/* Pink smoke layer 2 — opposite direction, different positions, longer cycle */
body::after {
  content: '';
  position: fixed;
  inset: -40%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 65% 25%, rgba(252, 0, 154, 0.32) 0%, transparent 38%),
    radial-gradient(circle at 25% 80%, rgba(252, 0, 154, 0.28) 0%, transparent 38%);
  animation: smokeRotateReverse 80s linear infinite;
  will-change: transform;
  filter: blur(60px);
}

@keyframes smokeRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes smokeRotateReverse {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* Disable on reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

.logo { height: 32px; width: auto; display: block; margin: 0 auto; }

/* ---------- Login ---------- */
.page-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  text-align: center;
  padding: 32px 24px;
  background: var(--card);
  border-radius: var(--radius);
}
.login-card .logo { height: 40px; margin: 0 auto 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 12px 16px; font-size: 16px;
  background: #0e0e10; color: var(--fg);
  border: 1px solid #2a2a30; border-radius: var(--radius);
}
.login-card button {
  padding: 12px 16px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: white;
  border: 0; border-radius: var(--radius); cursor: pointer;
}
.msg { color: var(--accent); font-size: 14px; min-height: 18px; margin: 4px 0 0; }

/* ---------- Search ---------- */
.page-search {
  max-width: 540px; margin: 0 auto; padding: 12px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  gap: 28px;
}
.topbar { text-align: center; padding: 8px 4px 0; }
.topbar .logo { margin: 0 auto; }
.tagline {
  color: #ffffff; font-size: 16px; line-height: 1.5;
  margin: 18px 12px 0; text-align: center;
  font-weight: 400;
}

/* Initial (hero) state — no .searched class on body */
.page-search:not(.searched) {
  justify-content: center;
  gap: 48px;
}
.page-search:not(.searched) .topbar { padding-top: 0; }
.page-search:not(.searched) .logo { height: 44px; }
.page-search:not(.searched) .tagline { margin-top: 32px; font-size: 17px; }
.page-search:not(.searched) #results,
.page-search:not(.searched) .status { display: none; }

/* After-search state */
.page-search.searched .tagline { display: none; }
.page-search.searched #results { flex: 1; }
.page-search.searched .search-bar {
  position: sticky; bottom: 0;
  background: var(--bg);
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  margin-top: auto;
}

.search-bar {
  display: flex; gap: 8px;
}
.search-bar input {
  flex: 1; padding: 12px 16px; font-size: 16px;
  background: var(--card); color: var(--fg);
  border: 1px solid #2a2a30; border-radius: 24px;
}
.search-bar input::placeholder {
  font-size: 13px; opacity: 0.7;
}
.search-bar button {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: white;
  border: 0; cursor: pointer;
  font-size: 20px;
}
.search-bar button.listening {
  background: var(--accent); animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.tile {
  position: relative;
  aspect-ratio: 9/16;
  border-radius: var(--radius); overflow: hidden;
  background: var(--card);
  cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tile-badge {
  position: absolute; top: 6px; left: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.tile .tile-badge-icon {
  width: 14px; height: 14px;
  filter: brightness(0) invert(1);
}
.tile .tile-title {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 24px 8px 8px;
  font-size: 11px; font-weight: 600; line-height: 1.3;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}
.tile .tile-duration {
  position: absolute; top: 6px; right: 6px;
  font-size: 10px;
  background: rgba(0,0,0,0.6); padding: 2px 5px; border-radius: 4px;
}
.skeleton { background: linear-gradient(90deg, #1a1a1d, #2a2a30, #1a1a1d); background-size: 200% 100%; animation: skel 1.4s infinite; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.no-results {
  grid-column: 1 / -1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  font-weight: 700; font-size: 18px; line-height: 1.5;
  color: #ffffff;
  min-height: 50vh;
  padding: 32px 20px;
}

.status { text-align: center; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* ---------- Modal player ---------- */
.player {
  position: fixed; inset: 0;
  background: black; z-index: 100;
  display: flex; flex-direction: column;
}
.player.hidden { display: none; }
#player-stage {
  flex: 1; position: relative; background: black;
  display: flex;
}
.player iframe, #yt-mount {
  flex: 1; width: 100%; border: 0; background: black;
}
#yt-mount.hidden { display: none; }
#yt-mount iframe { width: 100%; height: 100%; border: 0; }
.player-fallback {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); padding: 40px;
}
.player-fallback.hidden { display: none; }
.player-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid #2a2a30;
}
.player-bar button, .player-bar a {
  background: var(--accent); color: white;
  padding: 10px 16px; border-radius: var(--radius);
  border: 0; text-decoration: none; cursor: pointer;
  font-size: 14px; font-weight: 600;
}
