.channel-view {
  display: flex;
  height: 100%;
  background: var(--bg-primary);
}

.sidebar {
  width: 380px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-title {
  min-width: 0;
}

.settings-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  cursor: pointer;
}

.settings-btn.focused,
.settings-btn:hover {
  color: #fff;
  background: var(--accent-dim);
  outline: none;
}

.sidebar-header h2 {
  font-size: 26px;
  color: var(--accent-text);
}

.channel-count {
  font-size: 18px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Playlist tabs */
.playlist-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.playlist-tab {
  padding: 10px 16px;
  font-size: 18px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
}

.playlist-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  background: var(--accent-quiet);
  border-color: transparent;
}

/* Top-level content sections: Live / Movies / Series. A segmented row above the
   group list; only shown when the playlist carries more than one section. */
.kind-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 8px 4px;
  flex-shrink: 0;
}

.kind-tab {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.kind-tab.active {
  color: var(--accent-text);
  background: var(--accent-quiet);
  border-color: transparent;
}

/* "← Show name" row above the season list, shown while inside a series. */
.series-back {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A series folder row (drill into its episodes) reuses .channel-item layout. */
.series-chevron {
  font-size: 24px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* --- Poster grid (Movies & Series folders) ------------------------------- */
.poster-card {
  /* position/size set inline (virtualised cell); this is the inner padding box */
  padding: 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--radius-card);
}

.poster-thumb {
  position: relative;
  width: 100%;
  /* Fill the virtualised cell's remaining height (the cell height is set inline
     and is smaller on phones) so the poster never overflows into the next row. */
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius-art);
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-fallback {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 700;
  color: var(--text-muted);
}

.poster-title {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poster-sub {
  font-size: 18px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poster-card.focused {
  border-color: var(--focus-gap) !important;
  background: var(--bg-tertiary);
}

.poster-card.playing .poster-thumb {
  outline: 3px solid var(--accent);
}

/* --- Series detail header (Xtream) --------------------------------------- */
.series-detail {
  display: flex;
  gap: 20px;
  padding: 8px 0 20px;
}

.series-detail-poster {
  position: relative;
  width: 180px;
  height: 270px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.series-detail-poster img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-detail-meta {
  flex: 1;
  min-width: 0;
}

.series-detail-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.series-detail-sub {
  font-size: 18px;
  color: var(--accent-text);
  margin-bottom: 12px;
}

.series-detail-plot {
  font-size: 18px;
  line-height: 1.4;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.series-detail-cast {
  font-size: 18px;
  color: var(--text-muted);
}

/* Movie detail: a bigger poster + a prominent Play button. */
.movie-detail .series-detail-poster {
  width: 240px;
  height: 360px;
}

.movie-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 16px 40px;
  font-size: 26px;
  font-weight: 700;
  color: #04121a;
  background: var(--accent);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.movie-play-btn.focused {
  border-color: #fff !important;
  box-shadow: var(--focus-shadow);
}

.detail-actions {
  margin-top: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.detail-actions .movie-play-btn {
  margin-top: 0;
}

.watchlist-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  font-size: 24px;
  font-weight: 700;
  color: #eaf6ff;
  background: var(--surface-b);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.watchlist-btn.focused {
  border-color: #fff !important;
  box-shadow: var(--focus-shadow);
}

.group-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.group-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  margin: 4px 0;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}

.group-item.active {
  background: var(--accent-quiet);
  border-color: transparent;
}

.group-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  /* Muted by default: a full column of accent-red icons competes with the
     selection itself. The active row promotes its own icon below. */
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-icon .icon {
  width: 24px;
  height: 24px;
}

.group-item.active .group-icon,
.group-item.focused .group-icon { color: var(--accent-text); }

.group-name {
  flex: 1;
  font-size: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  font-size: 18px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

/* Channel main area */
.channel-main {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.channel-search {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px 0 12px;
  display: flex;
  justify-content: flex-end;
}

.channel-search-input {
  width: 440px;
  max-width: 100%;
  padding: 14px 18px;
  font-size: 26px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.channel-search-input::placeholder {
  color: var(--text-muted);
}

/* Virtualised list: rows are absolutely positioned at `pos * 88px` and the
   container is given an explicit height in JS so only the on-screen rows exist
   in the DOM (see channel-list.ts). A plain flex column rendering every channel
   freezes the engine on large playlists. */
.channel-list-scroll {
  position: relative;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  gap: 16px;
  height: 84px;
}

.channel-item.playing {
  background: rgba(228, 32, 47, 0.14);
  border-color: var(--accent-dim);
}

.channel-number {
  font-size: 18px;
  color: var(--text-muted);
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.channel-logo-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-logo {
  max-width: 48px;
  max-height: 48px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.channel-logo-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  /* Muted like .poster-fallback: a placeholder letter marks missing artwork, it
     is not a signal. In accent red, a channel list with no logos became a column
     of red competing with the selected row. */
  color: var(--text-muted);
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-now {
  font-size: 18px;
  line-height: 1.25;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "Continue watching" progress on a series episode row. */
.ep-resume-bar {
  margin-top: 6px;
  height: 4px;
  width: 60%;
  max-width: 320px;
  background: var(--surface-c);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ep-resume-fill {
  height: 100%;
  background: var(--accent);
}

.playing-indicator {
  font-size: 20px;
  color: var(--accent-text);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
