:root {
  --bg-color: #050505;
  --surface-color: #1a1a1a;
  --accent-color: #E50914; /* Netflix Red */
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --header-height: 80px;
  --glass-bg: rgba(5, 5, 5, 0.85);
  --radius: 8px;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-y: scroll; /* Prevent layout shift on scrollbar appear */
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 20px;
}

.search-wrapper {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  padding: 0 16px 0 20px;
  width: 100%;
  max-width: 400px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.search-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.search-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  width: 100%;
  outline: none;
  height: 100%;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.search-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.1);
}

.nav-toggles {
  display: flex;
  gap: 24px;
}

.nav-btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 0;
  position: relative;
  transition: color 0.2s;
}

.nav-btn-text:hover {
  color: var(--text-primary);
}

.nav-btn-text.active {
  color: var(--text-primary);
}

.nav-btn-text.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent-color);
  border-radius: 2px;
}

/* Main Layout */
.main-content {
  margin-top: var(--header-height);
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
  max-width: 1800px;
  margin-left: auto;
  margin-right: auto;
}

/* Saved Subs Bar */
.saved-subs-bar {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 24px;
  margin-bottom: 8px;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.saved-subs-bar::-webkit-scrollbar {
  display: none;
}

.sub-chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.sub-chip:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.sub-chip.active {
  background: var(--text-primary);
  color: black;
  border-color: var(--text-primary);
}

/* Grid Layout (Replaces Masonry) */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
}

/* Video Card */
.video-card {
  background-color: var(--surface-color);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
  position: relative;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(0,0,0,0.4);
  border-color: rgba(255,255,255,0.15);
}

.video-media-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.card-video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Ensures uniform shape */
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  transition: opacity 0.3s;
  color: white;
}

.play-overlay.hidden {
  opacity: 0;
}

.card-fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.video-card:hover .card-fav-btn,
.card-fav-btn:focus {
  opacity: 1;
  transform: scale(1);
}

.card-fav-btn:hover {
  background: rgba(255,255,255,0.15);
  transform: scale(1.1);
}

.card-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

.lightbox-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.lightbox-video-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.lightbox-video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  box-shadow: 0 0 100px rgba(0,0,0,0.5);
}

.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 1010;
  pointer-events: none; /* Let clicks pass through to background */
}

.lightbox-title-area {
  flex: 1;
  padding-right: 20px;
}

.lightbox-title-area h2 {
  color: white;
  font-size: 18px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.lightbox-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.icon-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.05);
}

.lightbox-controls {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  pointer-events: none;
  z-index: 1005;
}

.nav-btn {
  pointer-events: auto;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.nav-btn:hover {
  background: rgba(255,255,255,0.15);
  transform: scale(1.1);
}

/* Animations */
.fade-in {
  animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Status & Loading */
.status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-secondary);
  animation: fadeIn 0.5s ease;
}

.empty-state svg {
  margin-bottom: 24px;
  opacity: 0.3;
}

.empty-state h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-weight: 700;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

.loader-sentinel {
  height: 60px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}

.mini-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s linear infinite;
}

.error-text {
  color: #ff4d4d;
  font-size: 16px;
  font-weight: 600;
}