:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242e;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --accent: #4f8cff;
  --radius: 12px;
  --gap: 1.25rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.site-header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

.site-header.compact {
  text-align: left;
  padding: 1rem 1.5rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.tagline {
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover {
  text-decoration: underline;
}

/* Search */
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.1rem auto 0;
  max-width: 720px;
  width: 100%;
}

.site-header.compact .search-form {
  margin: 0.85rem 0 0;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  border-color: var(--accent);
}

.search-button {
  padding: 0.65rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.search-button:hover {
  opacity: 0.9;
}

.search-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Segmented Movies / TV toggle */
.search-toggle {
  display: inline-flex;
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.search-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.search-toggle-label {
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-toggle-label:hover {
  color: var(--text);
}

.search-toggle-input:checked + .search-toggle-label {
  background: var(--accent);
  color: #fff;
}

.search-toggle-input:focus-visible + .search-toggle-label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Search result sections (All view) */
.result-section {
  margin-top: 1.75rem;
}

.result-section:first-of-type {
  margin-top: 0.5rem;
}

.result-section-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: var(--muted);
}

/* Gallery grid */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card-thumb {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

.card-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2rem;
}

.card-body {
  padding: 0.85rem 1rem 1.1rem;
}

.card-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Player */
.player-wrap {
  max-width: 960px;
  margin: 0 auto;
}

.player {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-title {
  margin: 1rem 0 0.25rem;
}

.video-description {
  color: var(--muted);
  margin: 0;
}

/* Misc */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.empty-state code {
  background: var(--surface-2);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1.5rem 3rem;
}

.attribution {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* Content sections (library + new releases, TMDB) */
.content-section {
  margin-top: 2.5rem;
}

.content-section:first-child {
  margin-top: 0.5rem;
}

.section-title {
  margin: 0 0 0.2rem;
  font-size: 1.4rem;
}

.section-subtitle {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.release-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: var(--gap);
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.release-card {
  scroll-snap-align: start;
  text-decoration: none;
  color: var(--text);
}

/* Search results (wrapping grid of poster cards) */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--gap);
}

.results-grid .release-card {
  scroll-snap-align: unset;
}

.results-grid .release-poster {
  width: 100%;
}

.results-pager {
  display: flex;
  justify-content: center;
  margin-top: 1.75rem;
}

.release-poster {
  width: 150px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--surface-2);
  display: block;
}

.release-title {
  margin: 0.5rem 0 0.15rem;
  font-size: 0.9rem;
  line-height: 1.25;
}

.release-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Movie details page */
.movie-hero {
  height: 320px;
  margin: -1.5rem -1.5rem 0;
  background-size: cover;
  background-position: center 20%;
  border-radius: 0 0 var(--radius) var(--radius);
}

.movie-top {
  display: flex;
  gap: 1.75rem;
  margin-top: -120px;
  position: relative;
  flex-wrap: wrap;
}

/* No backdrop: drop the hero overlap so content starts below the header. */
.no-hero .movie-top {
  margin-top: 1rem;
}

.no-hero .movie-info {
  padding-top: 0;
}

.movie-poster {
  width: 220px;
  max-width: 40vw;
  height: auto;
  align-self: flex-start;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.movie-info {
  flex: 1;
  min-width: 260px;
  padding-top: 130px;
}

.movie-title {
  margin: 0 0 0.3rem;
  font-size: 2rem;
  line-height: 1.15;
}

.movie-tagline {
  margin: 0 0 1rem;
  color: var(--muted);
  font-style: italic;
}

.movie-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.play-button:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.play-icon {
  font-size: 0.85em;
}

.fact-chip {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text);
}

.movie-section-title {
  font-size: 1.3rem;
  margin: 1.75rem 0 0.75rem;
}

.movie-overview {
  margin: 0 0 1.25rem;
  max-width: 70ch;
}

.movie-detail {
  margin: 0.3rem 0;
  font-size: 0.92rem;
}

.movie-detail-label {
  color: var(--muted);
  font-weight: 600;
}

.movie-links {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.movie-ext-link {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.movie-ext-link:hover {
  border-color: var(--accent);
}

.trailer-wrap {
  max-width: 800px;
}

.trailer {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius);
  background: #000;
}

.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--gap);
}

.cast-card {
  text-align: center;
}

.cast-photo {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: block;
}

.cast-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--muted);
}

.cast-name {
  margin: 0.45rem 0 0.1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.cast-character {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

a {
  color: var(--accent);
}

/* TV badge on library cards */
.type-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  vertical-align: middle;
}

/* Season selector on the show details page */
.season-select {
  margin: 0 0 1rem;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  /* Custom arrow inset from the right edge so there's space beside it. */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa0ab' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.season-block {
  margin-bottom: 1rem;
}

.season-heading {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--muted);
}

/* Episode list (show details page) */
.episode-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.episode {
  display: flex;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.episode.playable {
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.episode.playable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.episode-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
}

.episode-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.episode-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--muted);
}

.episode-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.episode.playable:hover .episode-play {
  opacity: 1;
}

.episode-body {
  padding: 0.7rem 0.9rem;
  min-width: 0;
}

.episode-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.episode-number {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.85rem;
}

.episode-title {
  font-weight: 600;
}

.episode-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

.episode-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.episode-overview {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Episode picker on the player page */
.episode-picker {
  margin-top: 1.75rem;
}

.episode-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.episode-switch-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.episode-switch {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

a.episode-switch:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.episode-switch.current {
  border-color: var(--accent);
  background: var(--surface-2);
}

.episode-switch-thumb {
  flex-shrink: 0;
  width: 92px;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
}

.episode-switch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.episode-switch-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.episode-switch-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem 0.4rem 0;
  min-width: 0;
}

.episode-switch-number {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.episode-switch-title {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

