:root {
  --bg: #0b0b0f;
  --bg-2: #15151c;
  --fg: #f5f5f7;
  --muted: #9aa0aa;
  --accent: #e50914;
  --card-radius: 8px;
  --gap: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(11,11,15,0.95), rgba(11,11,15,0.6));
  backdrop-filter: blur(8px);
}
.brand { font-weight: 800; font-size: 20px; color: var(--accent); letter-spacing: .5px; white-space: nowrap; }
#search {
  width: 280px; max-width: 40vw;
  background: var(--bg-2); color: var(--fg);
  border: 1px solid #2a2a33; border-radius: 20px;
  padding: 8px 14px; font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); }
.spacer { flex: 1; }
.user {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6d28d9, #2563eb);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

/* ---------- Hero ---------- */
.hero {
  position: relative; height: 56vh; min-height: 340px;
  background-size: cover; background-position: center top;
  display: flex; align-items: flex-end;
}
.hero-fade {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(11,11,15,0.95) 0%, rgba(11,11,15,0.5) 40%, transparent 70%),
              linear-gradient(0deg, var(--bg) 2%, transparent 40%);
}
.hero-inner { position: relative; padding: 0 48px 40px; max-width: 720px; }
.hero-inner h1 { font-size: clamp(28px, 5vw, 52px); margin: 0 0 10px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.overview { font-size: 15px; line-height: 1.5; color: #d7d9de; margin: 0 0 18px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.btn-play {
  background: var(--fg); color: #111; border: 0; cursor: pointer;
  font-size: 16px; font-weight: 700; padding: 10px 26px; border-radius: 6px;
}
.btn-play:hover { background: #d7d7da; }

/* ---------- Rows ---------- */
#rows { padding: 8px 0 60px; }
.row { margin: 26px 0; }
.row h2 { font-size: 18px; margin: 0 0 12px; padding: 0 24px; }
.row-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: 180px;
  gap: var(--gap); overflow-x: auto; padding: 0 24px 8px;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.row-track::-webkit-scrollbar { height: 8px; }
.row-track::-webkit-scrollbar-thumb { background: #2a2a33; border-radius: 4px; }

.card {
  scroll-snap-align: start; cursor: pointer;
  border-radius: var(--card-radius); overflow: hidden;
  background: var(--bg-2); transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.card:hover { transform: scale(1.06); box-shadow: 0 8px 28px rgba(0,0,0,.6); z-index: 2; }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: #222; }
.card .card-title { padding: 8px 10px; font-size: 13px; color: #e7e7ea; }
.badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.7); border: 1px solid #3a3a44;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; color: #cfd2d8;
}
.empty { padding: 80px 24px; color: var(--muted); text-align: center; }
.empty code { background: var(--bg-2); padding: 2px 8px; border-radius: 4px; }

/* ---------- Player ---------- */
.player {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: flex; align-items: center; justify-content: center;
}
#video { width: 100%; height: 100%; background: #000; }
.close {
  position: absolute; top: 16px; right: 20px; z-index: 110;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(20,20,26,.7); color: #fff; font-size: 18px;
}
.close:hover { background: rgba(40,40,50,.9); }

.trackbar {
  position: absolute; bottom: 76px; right: 24px; z-index: 110;
  display: flex; gap: 10px;
}
.menu { position: relative; }
.menu-btn {
  background: rgba(20,20,26,.82); color: #fff; border: 1px solid #34343e;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.menu-btn:hover { background: rgba(40,40,50,.95); }
.menu-list {
  list-style: none; margin: 0; padding: 6px; position: absolute; bottom: 44px; right: 0;
  min-width: 180px; background: rgba(18,18,24,.97); border: 1px solid #34343e;
  border-radius: 8px; display: none; max-height: 260px; overflow-y: auto;
}
.menu-list.open { display: block; }
.menu-list li {
  padding: 8px 12px; border-radius: 5px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.menu-list li:hover { background: #2a2a33; }
.menu-list li.active { color: var(--accent); font-weight: 700; }
.menu-list li.active::before { content: "✓ "; }

.toast {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); border: 1px solid #34343e; color: #fff;
  padding: 8px 16px; border-radius: 20px; font-size: 13px; z-index: 115;
}

@media (max-width: 640px) {
  .hero-inner { padding: 0 20px 28px; }
  .row-track { grid-auto-columns: 132px; }
  #search { width: 160px; }
  .trackbar { right: 10px; bottom: 64px; }
}
