header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2vh;
  width: 100%;
}

.search-container {
  width: 90%;
  max-width: 500px;
  margin: 0 auto 4vh;
  display: flex;
  gap: 1vw;
  justify-content: center;
  padding: 0 2vw;
  box-sizing: border-box;
}

.media-section {
  margin-bottom: 4vh;
  width: 100%;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2vw;
  padding: 2vh 0;
  width: 100%;
}

.similar-media-section {
  margin: 2vh 0 0 0;
  padding: 0;
  width: 100%;
}

.similar-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2vw;
  width: 100%;
}

/* --- SIDEBAR & GENRE LIST (from base.css) --- */
.sidebar {
  position: fixed;
  left: -480px; /* Fully off-screen */
  top: 0;
  bottom: 0;
  height: 100vh; /* Full height */
  width: min(420px, 85vw); 
  min-width: 280px;
  
  /* Professional Dark Glass Look */
  background-color: rgba(12, 12, 12, 0.85); 
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  
  /* Smooth Cubic Bezier Transition */
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1), left 0.5s cubic-bezier(0.19, 1, 0.22, 1), box-shadow 0.5s ease;
  
  z-index: 5000;
  padding-top: calc(12vh - 75px); /* Reduced by 75px so MOVIES sits higher */
  padding-left: 30px;
  padding-right: 30px;
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6);
  overflow-y: auto;
  border-radius: 0;
  transform: translateX(0);

  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar {
  display: none; /* WebKit (Chrome/Safari) */
}

/* Desktop / tablet open state */
@media (min-width: 481px) {
  .sidebar.open {
    left: 0; /* Dock to edge */
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0,0,0,0.8);
  }
}

/* Sidebar title removed per design – keep selector hidden for safety */
.sidebar-title {
  display: none !important;
}

.sidebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  /* NEW: circular ball-style close button */
  width: 42px;               /* ~20% larger than typical icon size */
  height: 42px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: #ffffff;
  font-size: 2.16rem;        /* 20% larger than previous 1.8rem */
  cursor: pointer;
  display: none;             /* hide close icon in category window */
  align-items: center;
  justify-content: center;
  z-index: 5001;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.sidebar-close:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0.9;
}

.genre-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns for a more spacious, professional grid */
  gap: 16px; /* Consistent pixel gap */
  padding: 0 0 60px 0;
  margin: 0;
  list-style: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --- COLOR BALL UI (from styles.css/base.css) --- */
.color-ball-container {
  position: fixed;
  top: 2vh;
  right: 2vw;
  z-index: 500; 
  display: flex;
  flex-direction: row; /* align balls in a row */
  gap: 10px;          /* even spacing */
  align-items: center;
}

/* Base style for all top action balls to match theme ball */
.action-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  /* 3D glass base (no flat background; use gradient + inner shadow below) */
  box-shadow:
    0 4px 10px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.08) 40%,
    rgba(0,0,0,0.20) 100%
  );
  border: 2px solid rgba(255,255,255,0.3);
  opacity: 0.85;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  user-select: none;
  position: relative;
  overflow: hidden; /* clip reflection to circle */
}

/* Glassy highlight band across top half of round buttons */
.action-ball::before {
  content: "";
  position: absolute;
  inset: 0;
  /* use a curved radial highlight instead of a flat band */
  background: radial-gradient(
    circle at 30% 0%,
    rgba(255,255,255,0.9) 0%,
    rgba(255,255,255,0.4) 35%,
    rgba(255,255,255,0.0) 65%
  );
  opacity: 0.9;
  pointer-events: none;
}

/* NEW: Ensure the settings sprocket SVG is centered and sized within the circle */
.settings-ball svg {
  width: 60%;
  height: 60%;
  display: block;
}

/* Ensure the standalone color ball is circular and visually consistent */
.color-ball {
  width: 50px;
  height: 50px;
  min-width: 35px;
  min-height: 35px;
  border-radius: 50%;
  /* Match 3D glass look of action balls */
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.08) 40%,
    rgba(0,0,0,0.20) 100%
  );
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow:
    0 4px 10px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.35);
  opacity: 0.85;
  display: inline-block;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}

.color-ball::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 0%,
    rgba(255,255,255,0.9) 0%,
    rgba(255,255,255,0.4) 35%,
    rgba(255,255,255,0.0) 65%
  );
  opacity: 0.9;
  pointer-events: none;
}

/* Keep mobile sizing but preserve circular shape */
@media (max-width: 768px) {
  .color-ball {
    width: 35px !important;
    height: 35px !important;
    min-width: 35px !important;
    min-height: 35px !important;
    border-radius: 50% !important;
    display: inline-block;
  }

  .action-ball {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
  }
}

.action-ball-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

[data-theme]:not([data-theme^="light"]) .action-ball-icon {
  filter: invert(1);
}



.action-ball:hover {
  background: var(--background-color);
  border: 2px solid var(--lighter-primary-color);
  transform: scale(1.1);
}

/* Light theme contrast tweaks */
[data-theme^="light"] .action-ball {
  border-color: var(--text-color);
  color: #000000;
}
[data-theme^="light"] .action-ball:hover {
  background: var(--background-color);
  border-color: var(--primary-color);
  color: #000000;
}

/* Mobile sizing to match theme ball */
@media (max-width: 768px) {
  .action-ball {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
  }

  .action-ball-icon {
    width: 20px;
    height: 20px;
  }
}

.color-tooltip {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  display: none !important;
  z-index: 1001;
}

.color-tooltip::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
}

/* --- SCROLL TO TOP UI (from base.css) --- */
.scroll-to-top-container {
    position: fixed;
    bottom: 2vh; 
    right: 2vw; 
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Reposition tooltip for the bottom element */
.scroll-to-top-container .color-tooltip {
    top: auto; 
    bottom: 60px; 
    transform: translateX(-50%);
}

.scroll-to-top-container .color-tooltip::before {
    top: auto;
    bottom: -5px; 
    border-width: 5px 5px 0 5px;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

/* Styles for the Scroll Top Ball (Up Arrow) */
.scroll-top-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  /* 3D glass look */
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.08) 40%,
    rgba(0,0,0,0.20) 100%
  );
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.2rem; 
  font-weight: 900; 
  cursor: pointer;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.35);
  
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, visibility 0.5s ease, transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Reflection on scroll-top ball */
.scroll-top-ball::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 0%,
    rgba(255,255,255,0.9) 0%,
    rgba(255,255,255,0.4) 35%,
    rgba(255,255,255,0.0) 65%
  );
  opacity: 0.9;
  pointer-events: none;
}
/* New: caret icon styling inside scroll-to-top ball */
.scroll-top-ball .scroll-top-caret {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.scroll-top-ball.visible {
  opacity: 0.8;
  visibility: visible;
  pointer-events: auto; 
  transform: translateY(-5px); 
}

.scroll-top-ball:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Ensure text color is black for light themes where primary color is light */
[data-theme^="light"] .scroll-top-ball {
    color: #000000;
}

/* --- MODAL PLAYER UI ELEMENTS (from layout.css) --- */
#seasonSelect,
#episodeSelect {
  padding: 1.2vh 2vh;
  margin: 1vh;
  min-width: 20vw;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#seasonSelect option,
#episodeSelect option {
  padding: 0.8vh;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
}

#seasonEpisodeSelector {
  margin: 2.5vh 0;
  display: flex;
  gap: 1.5vh;
  flex-wrap: wrap;
  align-items: center;
}

#seasonEpisodeSelector button {
  padding: 1.2vh 2.4vh;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#seasonEpisodeSelector button:hover {
  background-color: #f40612;
}

.media-server-selector {
  margin: 1vh 0;
  width: 100%;
  padding: 0.8vh 1.2vh;
  background: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.episode-navigation {
  display: flex;
  gap: 1vw;
  margin: 2vh 0;
  justify-content: center;
  align-items: center;
}

.episode-info {
  font-size: 1.1rem;
  color: var(--text-color);
  margin: 0 2vw;
}

.nav-button {
  padding: 1.2vh 2.4vh;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.nav-button:hover {
  background-color: #f40612;
}

.nav-button:disabled {
  background-color: #666;
  cursor: not-allowed;
}

/* Media queries related to sidebar/genre list sizing */
@media (max-width: 600px) {
  .genre-item {
    font-size: calc(1rem - 4px);
    padding: 0.5vh 0.9vh;
  }

  .genre-header {
    font-size: calc(0.9rem - 4px);
    padding: 0.5vh 1.5vh;
  }
}

@media (max-width: 480px) {
  .genre-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
  }

  .sidebar {
    width: 100%; 
    left: -100%;
    top: 0;
    bottom: 0;
    height: 100vh;
    background-color: rgba(10, 10, 10, 0.95); /* Solid backing for mobile legibility */
    padding-top: 90px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 40px;
  }

  .sidebar.open {
    left: 0;
    transform: none;
  }
}

/* Light theme override: make the category window panel light so dark text is readable */
[data-theme^="light"] .sidebar {
  background-color: rgba(255,255,255,0.95);
  border-right: 1px solid rgba(0,0,0,0.06);
  box-shadow: 10px 0 40px rgba(0,0,0,0.25);
}

/* Ensure headers inside the light sidebar use the theme primary color for good contrast */
[data-theme^="light"] .sidebar .genre-header {
  color: var(--primary-color) !important;
}

.settings-ball {
  border: none !important;
}

/* Ensure no border appears on hover */
.settings-ball:hover {
  border: none !important;
}

.search-ball {
  border: none !important;
}

.search-ball:hover {
  border: none !important;
}

/* Remove border specifically from the top category button */
.sidebar-toggle {
  border: none !important;
}

.sidebar-toggle:hover {
  border: none !important;
}

/* NEW: Info button (small round I button in lower-left) */
.info-ball {
  position: fixed;
  left: 1.5vw;
  bottom: 1.5vh;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  /* 3D glass look */
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.08) 40%,
    rgba(0,0,0,0.20) 100%
  );
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow:
    0 4px 10px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 500;
  opacity: 0.88;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Reflection for info ball */
.info-ball::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 0%,
    rgba(255,255,255,0.9) 0%,
    rgba(255,255,255,0.4) 35%,
    rgba(255,255,255,0.0) 65%
  );
  opacity: 0.9;
  pointer-events: none;
}

.info-ball:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 16px rgba(0,0,0,0.6);
  opacity: 0.96;
}

.info-ball-letter {
  font-family: "Abril Fatface", cursive;
  font-size: 1.5rem;
  font-style: italic;
  color: #ffffff;
  line-height: 1;
}

/* Light theme tweak: keep strong outline on info ball */
[data-theme^="light"] .info-ball {
  border-color: rgba(0,0,0,0.25);
}

/* Ensure it stays visible above scroll-to-top ball on small screens */
@media (max-width: 768px) {
  .info-ball {
    left: 2vw;
    bottom: 2vh;
    width: 38px;
    height: 38px;
  }
  .info-ball-letter {
    font-size: 1.3rem;
  }
}