.youtube-custom-player {
  color: #333333;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.02em;
  margin-top: -44px;
  padding-top: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.youtube-custom-player .player {
  position: sticky;
  top: 44px;
  width: 100%;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.85); /* Translucent background behind video */
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10; /* Above thumbnails */
  margin-bottom: 1.5rem;
  box-sizing: border-box;
}

.youtube-custom-player .video-container {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 896px;
  min-width: 320px;
  height: auto;
  overflow: hidden;
  margin: 0 auto;
  box-sizing: border-box;
}

.youtube-custom-player .video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  background: transparent; /* Ensure iframe doesn’t obscure background */
}

@supports not (aspect-ratio: 16 / 9) {
  .youtube-custom-player .video-container {
    padding-bottom: 56.25%;
    height: 0;
  }
  .youtube-custom-player .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

.youtube-custom-player .thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  z-index: 5; /* Below player */
}

.youtube-custom-player .thumbnails h2 {
  font-family: 'SF Pro Text', 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  padding: 0.75rem 0;
  color: #333;
  border-bottom: 1px solid #999;
  position: sticky;
  top: 0;
  background: rgba(241, 245, 249, 0.9);
  z-index: 6; /* Above thumbnails, below player */
}

.youtube-custom-player .thumbnail {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.youtube-custom-player .thumbnail:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.youtube-custom-player .thumbnail img {
  width: 100%;
  border-radius: 6px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.youtube-custom-player .thumbnail img:hover {
  transform: scale(1.03);
}

.youtube-custom-player .thumbnail p {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: #4b5563;
  text-align: center;
}

.youtube-custom-player .active-thumbnail {
  background: #e6f0ff;
  border: 2px solid #FF0000;
  transform: scale(1.02);
}

.youtube-custom-player .active-thumbnail img {
  border-radius: 4px;
}

.youtube-custom-player .error-notice {
  color: #dc2626;
  text-align: center;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}

body.media-mode .youtube-custom-player {
  height: calc(100vh - 140px);
  overflow-y: auto;
}

body.media-mode .youtube-custom-player .player {
  position: sticky;
  top: 44px;
  z-index: 10; /* Above thumbnails */
}

@media (max-width: 768px) {
  .youtube-custom-player {
    padding: 0.25rem;
  }

  .youtube-custom-player .video-container {
    min-width: 280px;
  }

  .youtube-custom-player .thumbnails {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  body.media-mode .youtube-custom-player {
    height: calc(100vh - 120px);
  }

  body.media-mode .youtube-custom-player .player {
    position: sticky;
    top: 44px;
    z-index: 10; /* Above thumbnails */
  }
}