/* Bebe Sleepy — YouTube-Music-style in-app catalogue.
   Dark base, branded red accent, mobile-first, safe-area aware. */

:root {
  --bg: #030305;
  --bg-elev: #0e0e12;
  --bg-elev-2: #16161c;
  --bg-card: #1b1b22;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-secondary: #b3b3bb;
  --text-muted: #6d6d76;
  --accent: #ff3b30;
  --accent-soft: #ff6b5d;
  --accent-deep: #c2110a;
  --radius: 16px;
  --radius-sm: 10px;
  --row-h: 64px;
  --mini-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
               "Helvetica Neue", system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
button { appearance: none; -webkit-appearance: none; background: none; border: none;
  color: inherit; font: inherit; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }

/* Topbar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding:
    max(8px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    8px
    max(16px, env(safe-area-inset-left));
  background: rgba(3, 3, 5, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px;
         font-weight: 700; letter-spacing: -0.01em; font-size: 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; position: relative;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 6px 16px rgba(255, 59, 48, 0.35);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px 6px auto auto;
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: -2px 4px 0 0 rgba(0, 0, 0, 0.45);
}
.iconbtn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  color: var(--text);
  transition: background 160ms ease, transform 120ms ease;
}
.iconbtn:active { background: rgba(255,255,255,0.08); transform: scale(0.95); }
.iconbtn svg { width: 22px; height: 22px; }

/* Search bar slide-down ----------------------------------------------- */
.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  transition: max-height 220ms ease, padding 220ms ease;
}
.searchbar[aria-hidden="false"] {
  max-height: 64px;
  padding: 12px 16px;
}
.searchbar input {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
}
.searchbar input:focus {
  border-color: rgba(255, 107, 93, 0.45);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.15);
}

/* Shell --------------------------------------------------------------- */
.shell {
  max-width: 880px;
  margin: 0 auto;
  /* Reserve mini-player height + safe-area at the bottom so the last
     row of the list never gets covered. */
  padding:
    16px
    max(16px, env(safe-area-inset-right))
    calc(var(--mini-h) + 24px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.shelf-title {
  font-size: 17px;
  font-weight: 700;
  margin: 8px 0 12px;
  letter-spacing: -0.005em;
}

/* Hero shelf (quick mixes) -------------------------------------------- */
.hero-shelf { margin-bottom: 28px; }
.hero-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 140px;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  margin: 0 -16px;
  padding: 4px 16px 8px;
  scrollbar-width: none;
}
.hero-row::-webkit-scrollbar { display: none; }
.hero-card {
  scroll-snap-align: start;
  text-align: left;
  transition: transform 140ms ease;
}
.hero-card:active { transform: scale(0.97); }
.hero-thumb {
  width: 140px; height: 140px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  background: linear-gradient(135deg, #333, #111);
  box-shadow: 0 10px 26px rgba(0,0,0,0.5);
}
.hero-thumb img,
.row-art img,
.mini-art img,
.np-art-full img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  /* Hint the renderer not to allocate full-res decode buffers for a
     tiny thumbnail. With this + decoding="async" the 80 KB JPEGs
     stream + decode in a worker thread and never block scroll. */
  image-rendering: auto;
  content-visibility: auto;
}
.hero-thumb.is-active::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2), transparent 65%);
  animation: pulse 2.6s ease-in-out infinite;
}
.hero-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-meta {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%      { opacity: 0.9;  transform: scale(1.08); }
}

/* Mood chips ---------------------------------------------------------- */
.moods { margin-bottom: 24px; }
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -16px;
  padding: 4px 16px 8px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.mood-chip {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 140ms ease;
}
.mood-chip.active {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(255, 59, 48, 0.35);
}

/* Compact row list (YT Music "Songs" style) --------------------------- */
.tracklist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.list-count { font-size: 12px; color: var(--text-muted); }
.rowlist { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  align-items: center;
  gap: 12px;
  height: var(--row-h);
  padding: 4px 4px;
  border-radius: 8px;
  text-align: left;
  transition: background 150ms ease;
}
.row:active { background: rgba(255,255,255,0.05); }
.row.active { background: rgba(255, 107, 93, 0.08); }
.row-art {
  width: 48px; height: 48px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2a30, #0d0d12);
}
.row.active .row-art::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 107, 93, 0.35), transparent 65%);
  animation: pulse 2.6s ease-in-out infinite;
}
.row-body { min-width: 0; }
.row-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-meta {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-tags {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.row-duration {
  font-size: 12px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* License badge — color-coded by family. Tap to open the license
   bottom sheet showing the full terms. */
.lic-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.lic-badge.lic-yt {
  background: rgba(255, 59, 48, 0.12);
  color: var(--accent-soft);
  border-color: rgba(255, 59, 48, 0.30);
}
.lic-badge.lic-attr {
  background: rgba(255, 159, 10, 0.12);
  color: #ffb347;
  border-color: rgba(255, 159, 10, 0.30);
}
.lic-badge.lic-cc {
  background: rgba(48, 209, 88, 0.12);
  color: #4ad57f;
  border-color: rgba(48, 209, 88, 0.30);
}
.lic-badge.lic-proc {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border-color: var(--line-strong);
}
#npLicense {
  margin-bottom: 22px;
  font-size: 11px;
  padding: 4px 10px;
}
/* Row needs slightly more height once we add the badge row. */
.row { height: auto; min-height: var(--row-h); padding: 8px 4px; }

/* License sheet body needs scrolling room for long terms. */
.sheet-inner-lic { max-height: 80vh; overflow-y: auto; }
.sheet-inner-lic .sheet-sub {
  white-space: pre-line;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 18px;
}
.row-more {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background 160ms ease, color 160ms ease;
}
.row-more:active { background: rgba(255,255,255,0.10); color: var(--text); }

.row-menu-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.row-menu-option .rm-label { font-size: 15px; font-weight: 600; color: var(--text); }
.row-menu-option .rm-hint  { font-size: 12px; color: var(--text-muted); }

/* Show more / empty --------------------------------------------------- */
.show-more {
  display: block;
  margin: 16px auto 0;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 16px;
}

/* Mini-player --------------------------------------------------------- */
.mini-player {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 48px 1fr 40px 48px 40px 40px;
  align-items: center;
  gap: 10px;
  padding:
    8px
    max(12px, env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: rgba(14, 14, 18, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.mini-art {
  width: 48px; height: 48px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
}
.mini-info { min-width: 0; }
.mini-title { font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-play { background: var(--text); color: #000; }
.mini-play:active { background: rgba(255,255,255,0.85); }
.mini-play .i-pause, .iconbtn.is-playing .i-play { display: none; }
.iconbtn.is-playing .i-pause { display: block; }
.iconbtn .i-pause { display: none; }
.iconbtn .i-play { display: block; }

/* Full-screen now-playing sheet --------------------------------------- */
.np-sheet {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding:
    max(16px, env(safe-area-inset-top))
    24px
    max(24px, env(safe-area-inset-bottom))
    24px;
  background: linear-gradient(180deg, #1a0a0a 0%, #050507 60%);
  transform: translateY(100%);
  transition: transform 360ms cubic-bezier(.2,.7,.2,1);
  z-index: 100;
  pointer-events: none;
}
.np-sheet[aria-hidden="false"] {
  transform: translateY(0);
  pointer-events: auto;
}
.np-close {
  align-self: flex-start;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
}
.np-close svg { width: 24px; height: 24px; color: var(--text); }
.np-art-full {
  width: min(70vw, 360px);
  aspect-ratio: 1;
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(80px, 16vw, 120px);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 28px 70px rgba(255, 59, 48, 0.45);
  margin: 12px 0 26px;
  position: relative;
  overflow: hidden;
}
.np-art-full.is-playing::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2), transparent 70%);
  animation: pulse 2.6s ease-in-out infinite;
}
.np-title-full {
  font-size: 24px; font-weight: 700;
  text-align: center;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.np-sub-full {
  font-size: 14px; color: var(--text-secondary);
  text-align: center;
  margin-bottom: 28px;
}
.np-controls {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 24px;
}
.np-side {
  width: 56px; height: 56px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.np-side svg { width: 26px; height: 26px; color: var(--text); }
.np-play {
  width: 80px; height: 80px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #000;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  box-shadow: 0 20px 42px rgba(255, 59, 48, 0.45);
}
.np-play svg { width: 34px; height: 34px; color: #fff; }
.np-play .i-pause, .np-play.is-playing .i-play { display: none; }
.np-play.is-playing .i-pause { display: block; }
.np-modes {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.mode-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 600;
}
.mode-pill.active {
  background: rgba(255, 107, 93, 0.18);
  color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 93, 0.4);
}
.mode-pill svg { width: 16px; height: 16px; }

/* Sleep timer sheet --------------------------------------------------- */
.sheet {
  position: fixed; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  pointer-events: none;
  background: rgba(0, 0, 0, 0);
  transition: background 260ms ease;
}
.sheet[aria-hidden="false"] {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.sheet-inner {
  width: 100%; max-width: 480px;
  background: var(--bg-elev);
  border-top-left-radius: 24px; border-top-right-radius: 24px;
  padding: 14px 22px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(.2,.7,.2,1);
}
.sheet[aria-hidden="false"] .sheet-inner { transform: translateY(0); }
.sheet-handle {
  width: 42px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.15);
  margin: 0 auto 12px;
}
.sheet h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.sheet-sub { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); }
.sheet-options { display: grid; gap: 8px; margin-bottom: 16px; }
.sheet-option {
  padding: 13px 16px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  font-size: 15px; font-weight: 600;
  text-align: left;
}
.sheet-option.active {
  border-color: rgba(255, 107, 93, 0.5);
  color: var(--accent-soft);
  background: linear-gradient(180deg, rgba(255,107,93,0.08), var(--bg-card));
}
.sheet-close {
  width: 100%; padding: 12px;
  border-radius: 999px; background: var(--text); color: #000;
  font-weight: 700; font-size: 15px;
}

/* Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
