:root {
  --black: #0a0a0a;
  --near-black: #141414;
  --red: #e50914;
  --red-dark: #b20710;
  --gray-text: #b3b3b3;
  --card-w: 220px;
}

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

body {
  background: var(--black);
  color: #fff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 4%;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, transparent 100%);
  transition: background 0.3s;
}
.topbar.scrolled { background: var(--near-black); }

.topbar-left { display: flex; align-items: center; gap: 36px; }

.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 1px;
  color: var(--red);
}
.logo span { color: #fff; }

.nav-links a {
  color: var(--gray-text);
  text-decoration: none;
  font-size: 14px;
  margin-right: 24px;
  transition: color 0.2s;
}
.nav-links a.active, .nav-links a:hover { color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.search-input {
  background: rgba(0,0,0,0.6);
  border: 1px solid #555;
  color: #fff;
  padding: 8px 12px;
  border-radius: 3px;
  font-size: 13px;
  width: 200px;
}
.search-input:focus { outline: none; border-color: #fff; }

.btn-upload {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-upload:hover { background: var(--red-dark); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  height: 85vh;
  min-height: 500px;
  background: radial-gradient(ellipse at top right, #3a0a0d 0%, var(--black) 60%);
  display: flex;
  align-items: flex-end;
}
.hero-fade {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, var(--black), transparent);
}
.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 4% 8%;
  max-width: 640px;
}
.hero-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 64px;
  letter-spacing: 1px;
  margin-bottom: 16px;
  line-height: 1.05;
}
.hero-desc {
  font-size: 16px;
  color: #eee;
  margin-bottom: 24px;
  line-height: 1.5;
  max-width: 560px;
}
.hero-buttons { display: flex; gap: 12px; }

.btn-play {
  background: #fff;
  color: #000;
  border: none;
  padding: 10px 26px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
}
.btn-play:hover { opacity: 0.8; }

.btn-info {
  background: rgba(109,109,110,0.7);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-info:hover { background: rgba(109,109,110,0.5); }

/* ---------- Rows ---------- */
.rows { padding: 20px 0 60px; margin-top: -60px; position: relative; z-index: 3; }

.row { margin-bottom: 38px; }
.row-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 4% 10px;
}
.row-track {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 4% 20px;
  scroll-behavior: smooth;
}
.row-track::-webkit-scrollbar { height: 0; }

.card {
  flex: 0 0 var(--card-w);
  width: var(--card-w);
  cursor: pointer;
  transition: transform 0.25s ease;
  position: relative;
}
.card:hover { transform: scale(1.08); z-index: 5; }

.card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 4px;
  background: #222 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23555"><path d="M8 5v14l11-7z"/></svg>') center/40px no-repeat;
  display: block;
}
.card-title {
  font-size: 13px;
  margin-top: 6px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 140px 20px;
}
.empty-state h2 { font-size: 26px; margin-bottom: 10px; }
.empty-state p { color: var(--gray-text); margin-bottom: 24px; }

/* ---------- Modals ---------- */
.modal-overlay, .player-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open, .player-overlay.open { display: flex; }

.modal {
  background: #181818;
  border-radius: 8px;
  width: 90%;
  max-width: 480px;
  padding: 32px;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.upload-modal h2 { margin-bottom: 20px; }
#uploadForm { display: flex; flex-direction: column; gap: 12px; }
#uploadForm input[type="text"],
#uploadForm input[type="number"],
#uploadForm textarea {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
.form-row { display: flex; gap: 10px; }
.form-row input { flex: 1; }

.dropzone {
  border: 2px dashed #555;
  border-radius: 4px;
  padding: 24px;
  text-align: center;
  color: var(--gray-text);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--red); color: #fff; }
.dropzone input { display: none; }

.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar { flex: 1; background: #333; border-radius: 4px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--red); height: 100%; width: 0%; transition: width 0.15s; }
#progressText { font-size: 12px; color: var(--gray-text); min-width: 36px; }

.info-modal { max-width: 560px; }
.info-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 18px;
}
#infoTitle { font-size: 24px; margin-bottom: 6px; }
.info-meta { color: var(--gray-text); font-size: 13px; margin-bottom: 14px; }
#infoDesc { font-size: 14px; line-height: 1.5; color: #ddd; margin-bottom: 20px; }
.info-actions { display: flex; gap: 12px; }
.btn-delete {
  background: transparent;
  border: 1px solid #666;
  color: #fff;
  padding: 10px 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.btn-delete:hover { border-color: var(--red); color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  :root { --card-w: 140px; }
  .hero-title { font-size: 38px; }
  .hero-desc { font-size: 13px; }
  .nav-links, .search-input { display: none; }
  .hero { height: 70vh; }
}

/* ---------- User menu ---------- */
.user-menu { position: relative; }
.user-chip {
  background: #333;
  color: #fff;
  border: none;
  padding: 6px 14px 6px 6px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip:hover { background: #444; }
.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), #6b0d12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.avatar-circle-lg { width: 76px; height: 76px; font-size: 26px; }
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #181818;
  border: 1px solid #333;
  border-radius: 6px;
  min-width: 170px;
  overflow: hidden;
  z-index: 50;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
  display: block;
  padding: 12px 16px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid #2a2a2a;
}
.user-dropdown a:last-child { border-bottom: none; }
.user-dropdown a:hover { background: #262626; }

/* ---------- Auth pages (login/setup) ---------- */
.auth-body {
  background: radial-gradient(ellipse at top, #2b0507 0%, var(--black) 55%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-wrap { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 20px; }
.auth-logo { font-size: 40px; }
.auth-card {
  background: rgba(0,0,0,0.75);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { font-size: 26px; margin-bottom: 8px; }
.auth-sub { color: var(--gray-text); font-size: 14px; margin-bottom: 20px; }
#authForm { display: flex; flex-direction: column; gap: 12px; }
#authForm input {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
.auth-submit { width: 100%; justify-content: center; margin-top: 6px; }
.auth-error {
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid var(--red);
  color: #ffb3b6;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- Admin page ---------- */
.admin-wrap { max-width: 760px; margin: 0 auto; padding: 110px 24px 60px; }
.admin-wrap h1 { font-size: 28px; margin-bottom: 6px; }
.admin-sub { color: var(--gray-text); font-size: 14px; margin-bottom: 28px; }
.admin-add-card {
  background: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 30px;
}
.admin-add-card h2 { font-size: 17px; margin-bottom: 16px; }
.admin-form { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-form input, .admin-form select {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}
.admin-form input { flex: 1; min-width: 140px; }

.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #2a2a2a;
  font-size: 14px;
}
.users-table th { color: var(--gray-text); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.role-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.role-admin { background: rgba(229,9,20,0.2); color: #ff6b70; }
.role-member { background: rgba(255,255,255,0.1); color: #ccc; }
.btn-small { padding: 6px 14px; font-size: 12px; }

/* ---------- Comments ---------- */
.comments-section { margin-top: 28px; border-top: 1px solid #2a2a2a; padding-top: 20px; }
.comments-section h3 { font-size: 15px; margin-bottom: 14px; color: #ddd; }
.comment-form { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-start; }
.comment-form textarea {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.comments-list { display: flex; flex-direction: column; gap: 14px; max-height: 260px; overflow-y: auto; }
.comment-item { font-size: 13px; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.comment-author { font-weight: 700; color: #fff; }
.comment-time { color: #888; font-size: 11px; }
.comment-delete {
  background: transparent;
  border: none;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  margin-left: auto;
}
.comment-delete:hover { color: var(--red); }
.comment-text { color: #ddd; line-height: 1.4; }
.comments-empty, .comments-loading { color: var(--gray-text); font-size: 13px; }

/* ---------- Profile modal ---------- */
.profile-avatar-row { display: flex; align-items: center; gap: 18px; margin: 18px 0 22px; }
.profile-avatar-upload { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-edit-label { font-size: 11px; color: var(--gray-text); }
.profile-avatar-upload:hover .avatar-edit-label { color: #fff; }
.profile-username { font-size: 18px; font-weight: 700; }
.profile-role { font-size: 12px; color: var(--gray-text); text-transform: capitalize; }
.field-label { display: block; font-size: 12px; color: var(--gray-text); margin-bottom: 6px; }
.profile-modal textarea {
  width: 100%;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.profile-bio-count { text-align: right; font-size: 11px; color: #777; margin: 4px 0 16px; }

/* ---------- Playlists ---------- */
.playlists-view { padding: 110px 4% 60px; }
.playlists-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.playlists-header h1 { font-size: 28px; }
.playlists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.playlist-card {
  background: #181818;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
  border: 1px solid #262626;
}
.playlist-card:hover { transform: translateY(-4px); border-color: #444; }
.playlist-card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 13px;
}
.playlist-card-body { padding: 12px 14px; }
.playlist-card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.playlist-card-meta { font-size: 12px; color: var(--gray-text); }
.playlists-empty { color: var(--gray-text); padding: 40px 0; max-width: 480px; }

.playlist-picker-modal .playlist-picker-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 20px; max-height: 300px; overflow-y: auto; }
.picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #262626;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.picker-row:hover { background: #303030; }
.picker-row.in-playlist { border: 1px solid var(--red); }
.picker-check { font-size: 12px; color: var(--red); font-weight: 700; }

#newPlaylistForm { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
#newPlaylistForm input, #newPlaylistForm textarea {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.playlist-detail-modal { max-width: 720px; }
.playlist-detail-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.playlist-detail-head h2 { font-size: 22px; margin-bottom: 4px; }
.playlist-detail-meta { font-size: 12px; color: var(--gray-text); margin-bottom: 8px; }
.playlist-detail-actions { display: flex; gap: 10px; align-items: flex-start; }
.playlist-detail-videos { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.playlist-video-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #202020;
  border-radius: 4px;
  padding: 8px;
}
.playlist-video-row img { width: 100px; aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; }
.playlist-video-row .pv-title { font-size: 14px; font-weight: 600; flex: 1; }
.playlist-video-row .pv-remove { background: transparent; border: none; color: #888; cursor: pointer; font-size: 13px; }
.playlist-video-row .pv-remove:hover { color: var(--red); }

/* ---------- Streamy custom video player ---------- */
.player-overlay { background: #000; align-items: stretch; justify-content: stretch; }
.player-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#videoPlayer {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
}
.player-center-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 74px; height: 74px;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
}
.player-center-icon.pulse { opacity: 1; transform: translate(-50%, -50%) scale(1.15); transition: none; }

.player-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 40px 24px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
  transition: opacity 0.25s;
}
.player-controls.hidden { opacity: 0; pointer-events: none; }

.player-progress-row { margin-bottom: 10px; }
.player-progress-bar {
  position: relative;
  height: 5px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  cursor: pointer;
  transition: height 0.15s;
}
.player-progress-bar:hover { height: 7px; }
.player-progress-buffered {
  position: absolute; top: 0; left: 0; height: 100%;
  background: rgba(255,255,255,0.35);
  border-radius: 3px;
  width: 0%;
}
.player-progress-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--red);
  border-radius: 3px;
  width: 0%;
}
.player-progress-handle {
  position: absolute;
  top: 50%; left: 0%;
  width: 13px; height: 13px;
  background: var(--red);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
}
.player-progress-bar:hover .player-progress-handle { transform: translate(-50%, -50%) scale(1); }

.player-controls-row { display: flex; align-items: center; gap: 14px; }
.player-controls-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.player-controls-center { flex: 2; text-align: center; min-width: 0; }
.player-controls-right { display: flex; align-items: center; gap: 10px; }

.player-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.9;
}
.player-btn:hover { opacity: 1; transform: scale(1.08); }

.volume-slider {
  width: 80px;
  accent-color: var(--red);
  cursor: pointer;
}
.player-time { font-size: 13px; color: #ddd; white-space: nowrap; }
.player-title-label {
  font-size: 13px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-speed-btn { font-size: 13px; font-weight: 700; width: auto; }

.player-up-next {
  position: absolute;
  bottom: 100px;
  right: 30px;
  background: #181818;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 14px;
  width: 220px;
  z-index: 20;
}
.up-next-label { font-size: 11px; color: var(--gray-text); text-transform: uppercase; margin-bottom: 8px; }
.up-next-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; margin-bottom: 8px; }
.up-next-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }

@media (max-width: 700px) {
  :root { --card-w: 140px; }
  .hero-title { font-size: 38px; }
  .hero-desc { font-size: 13px; }
  .nav-links, .search-input { display: none; }
  .hero { height: 70vh; }
  .player-controls-center { display: none; }
  .volume-slider { display: none; }
  .player-up-next { width: 160px; right: 12px; bottom: 90px; }
}
