* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #0e1322;
  color: #f3f6ff;
}

a {
  color: #7fb2ff;
}

.subtle {
  color: #a4afc8;
  margin: 0;
}

.error-box {
  margin: 10px 16px;
  padding: 10px;
  border-radius: 8px;
  background: #4a1515;
  border: 1px solid #7d2c2c;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #1f2940;
}

.topbar h1 {
  margin: 0 0 4px 0;
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-menu {
  display: inline-flex;
  gap: 6px;
}

.menu-link {
  border: 1px solid #2f3e62;
  background: #1a243b;
  color: #f3f6ff;
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
  font-size: 14px;
}

.menu-link.active {
  background: #24457d;
  border-color: #3e6ab3;
}

.filters {
  padding: 12px 16px;
  border-bottom: 1px solid #1f2940;
}

.filters form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters input,
.filters select,
.filters button,
.topbar button,
.player-actions button,
.login-form button {
  border: 1px solid #2f3e62;
  background: #1a243b;
  color: #f3f6ff;
  border-radius: 8px;
  padding: 8px 10px;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: calc(100vh - 130px);
}

.channels {
  border-right: 1px solid #1f2940;
  overflow: auto;
}

.channels-page {
  padding: 0 12px 12px;
  min-height: calc(100vh - 130px);
}

.channels-standalone {
  border: 1px solid #1f2940;
  border-radius: 10px;
  border-right: 1px solid #1f2940;
  background: #0f162a;
  max-height: calc(100vh - 210px);
}

.channels-standalone .group-block:last-child {
  border-bottom: 0;
}

.group-list {
  display: flex;
  flex-direction: column;
}

.group-block {
  border-bottom: 1px solid #1f2940;
}

.group-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 0;
  background: #111a2f;
  color: inherit;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.group-row:hover {
  background: #1a2742;
}

.group-row span {
  font-weight: 600;
}

.group-row small {
  color: #9eabca;
}

.group-channels {
  display: flex;
  flex-direction: column;
}

.group-channels.collapsed {
  display: none;
}

.group-channels-placeholder {
  padding: 8px 14px;
}

.channel-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid #1f2940;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.channel-row.active {
  background: #1f355a;
}

.group-channels .channel-row {
  padding-left: 18px;
}

.channel-row img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 6px;
  background: #0a0f1d;
}

.channel-row span {
  display: block;
  font-size: 14px;
}

.channel-row small {
  color: #9eabca;
}

.player-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

#video {
  width: 100%;
  height: min(66vh, 760px);
  background: #000;
  border-radius: 10px;
}

#nowPlaying {
  font-size: 14px;
  color: #b8c4df;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.movies-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 130px);
}

.movies-catalog {
  padding: 0 12px 12px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.channel-grid-placeholder {
  grid-column: 1 / -1;
  padding: 10px 0;
}

.channel-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.channel-page-btn {
  border: 1px solid #2b416f;
  background: #101a2e;
  color: #dbe7ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.channel-page-btn:hover:not(:disabled) {
  border-color: #4c80d4;
  background: #1a2a47;
}

.channel-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.channel-page-btn.active {
  border-color: #4c80d4;
  background: #244178;
  color: #ffffff;
  font-weight: 700;
}

.channel-page-dots {
  color: #8ea6d1;
  padding: 0 2px;
}

.channel-catalog-card {
  border: 1px solid #1f2940;
  border-radius: 10px;
  background: #101a2e;
  color: inherit;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.channel-catalog-card:hover {
  border-color: #3e6ab3;
  background: #15213a;
}

.channel-catalog-card img {
  width: 100%;
  height: 96px;
  object-fit: contain;
  border-radius: 8px;
  background: #0a0f1d;
  padding: 8px;
}

.channel-catalog-card span {
  font-size: 14px;
  line-height: 1.3;
  min-height: 36px;
}

.channel-catalog-card small {
  color: #9eabca;
}

.guide-updated {
  margin-left: 8px;
  white-space: nowrap;
}

.guide-table-root {
  min-height: 320px;
}

.guide-table-placeholder {
  padding: 10px 0;
}

.guide-table-wrap {
  border: 1px solid #1f2940;
  border-radius: 10px;
  overflow: auto;
  background: #101a2e;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.guide-table thead th {
  position: sticky;
  top: 0;
  background: #12203b;
  color: #e2ecff;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #2a3b61;
  font-size: 13px;
}

.guide-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #1f2940;
  vertical-align: top;
}

.guide-table tbody tr:hover {
  background: #15213a;
}

.guide-channel-cell {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.guide-channel-cell img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #0a0f1d;
  padding: 6px;
}

.guide-channel-cell strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.guide-channel-cell small {
  color: #9eabca;
}

.guide-program {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-program strong {
  font-size: 14px;
  line-height: 1.25;
}

.guide-program small {
  color: #9eabca;
}

.guide-progress {
  height: 6px;
  border-radius: 999px;
  background: #1f2940;
  overflow: hidden;
}

.guide-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3c74cf 0%, #6ca7ff 100%);
}

.guide-status-cell {
  white-space: nowrap;
  color: #bfd0f5;
}

.guide-watch-btn {
  border: 1px solid #2f3e62;
  background: #1a243b;
  color: #f3f6ff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.guide-watch-btn:hover {
  border-color: #4c80d4;
  background: #1f2e4f;
}

.guide-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.guide-page-btn {
  border: 1px solid #2b416f;
  background: #101a2e;
  color: #dbe7ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.guide-page-btn:hover:not(:disabled) {
  border-color: #4c80d4;
  background: #1a2a47;
}

.guide-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guide-page-btn.active {
  border-color: #4c80d4;
  background: #244178;
  color: #ffffff;
  font-weight: 700;
}

.guide-page-dots {
  color: #8ea6d1;
  padding: 0 2px;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.movie-grid-placeholder {
  grid-column: 1 / -1;
  padding: 10px 0;
}

.movie-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.movie-page-btn {
  border: 1px solid #2b416f;
  background: #101a2e;
  color: #dbe7ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.movie-page-btn:hover:not(:disabled) {
  border-color: #4c80d4;
  background: #1a2a47;
}

.movie-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.movie-page-btn.active {
  border-color: #4c80d4;
  background: #244178;
  color: #ffffff;
  font-weight: 700;
}

.movie-page-dots {
  color: #8ea6d1;
  padding: 0 2px;
}

.movie-card {
  border: 1px solid #1f2940;
  border-radius: 10px;
  background: #101a2e;
  color: inherit;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.movie-card:hover {
  border-color: #3e6ab3;
  background: #15213a;
}

.movie-card.active {
  border-color: #4c80d4;
  background: #1d2d4b;
}

.movie-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #0a0f1d;
}

.movie-card span {
  font-size: 14px;
  line-height: 1.3;
  min-height: 36px;
}

.movie-player-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 90px);
}

.channel-player-layout {
  padding: 12px;
  min-height: calc(100vh - 90px);
}

.movie-poster-card {
  border: 1px solid #223051;
  border-radius: 10px;
  background: #111b30;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.movie-poster-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #0a0f1d;
}

.movie-poster-card h2 {
  margin: 0;
  font-size: 22px;
}

.movie-player-shell {
  border: 1px solid #223051;
  border-radius: 10px;
  background: #101a2e;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-player-shell {
  width: 100%;
}

#moviePlayerVideo {
  width: 100%;
  height: min(74vh, 820px);
  background: #000;
  border-radius: 10px;
}

#channelPlayerVideo {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border-radius: 10px;
}

.channel-player-actions {
  justify-content: flex-end;
}

#moviePlayerNowPlaying {
  font-size: 14px;
  color: #b8c4df;
}

.series-layout {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
  min-height: calc(100vh - 130px);
}

.series-catalog {
  padding: 12px;
  border-right: 1px solid #1f2940;
  overflow: auto;
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.series-grid-placeholder {
  grid-column: 1 / -1;
  padding: 10px 0;
}

.series-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.series-page-btn {
  border: 1px solid #2b416f;
  background: #101a2e;
  color: #dbe7ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.series-page-btn:hover:not(:disabled) {
  border-color: #4c80d4;
  background: #1a2a47;
}

.series-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.series-page-btn.active {
  border-color: #4c80d4;
  background: #244178;
  color: #ffffff;
  font-weight: 700;
}

.series-page-dots {
  color: #8ea6d1;
  padding: 0 2px;
}

.series-card {
  border: 1px solid #1f2940;
  border-radius: 10px;
  background: #101a2e;
  color: inherit;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.series-card:hover {
  border-color: #3e6ab3;
  background: #15213a;
}

.series-card.active {
  border-color: #4c80d4;
  background: #1d2d4b;
}

.series-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #0a0f1d;
}

.series-card span {
  font-size: 14px;
  line-height: 1.3;
  min-height: 36px;
}

.series-detail {
  padding: 12px;
  overflow: auto;
}

.series-detail-empty {
  padding: 12px;
  border: 1px dashed #2d3b5c;
  border-radius: 10px;
  background: #101a2e;
}

.series-detail-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.series-hero {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.series-hero img {
  width: 150px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #0a0f1d;
}

.series-hero h2 {
  margin: 0;
  font-size: 22px;
}

#seriesDetailMeta,
#seriesDetailPlot {
  margin-top: 6px;
}

#seriesVideo {
  width: 100%;
  height: min(48vh, 520px);
  background: #000;
  border-radius: 10px;
}

#seriesNowPlaying {
  font-size: 14px;
  color: #b8c4df;
}

.series-seasons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.series-season-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.season-tab {
  border: 1px solid #2f3e62;
  background: #1a243b;
  color: #f3f6ff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 38px;
}

.season-tab:hover {
  border-color: #3e6ab3;
  background: #1f2e4f;
}

.season-tab.active {
  border-color: #4c80d4;
  background: #23416e;
}

.season-block {
  border: 1px solid #223051;
  border-radius: 10px;
  background: #111b30;
  padding: 10px;
}

.season-title {
  margin: 0 0 8px;
  font-size: 15px;
}

.episode-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.episode-row {
  border: 1px solid #2f3e62;
  background: #18243d;
  color: inherit;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.episode-row:hover {
  border-color: #3e6ab3;
}

.episode-row.active {
  background: #23416e;
  border-color: #4c80d4;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(360px, 92vw);
  border: 1px solid #24314f;
  border-radius: 12px;
  background: #141c2f;
  padding: 18px;
}

.login-shell h1 {
  margin: 0 0 4px 0;
}

.login-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-form input {
  border: 1px solid #2f3e62;
  background: #0f1525;
  color: #f3f6ff;
  border-radius: 8px;
  padding: 8px 10px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .channels {
    border-right: 0;
    border-bottom: 1px solid #1f2940;
    max-height: 45vh;
  }

  .channels-standalone {
    border: 1px solid #1f2940;
    border-bottom: 1px solid #1f2940;
    max-height: none;
  }
  #video {
    height: 38vh;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .movies-layout {
    min-height: calc(100vh - 160px);
  }

  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  }

  .guide-updated {
    width: 100%;
    margin-left: 0;
  }

  .guide-table {
    min-width: 760px;
  }

  .movie-player-layout {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 160px);
  }

  #moviePlayerVideo {
    height: 40vh;
  }


  .series-layout {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 160px);
  }

  .series-catalog {
    border-right: 0;
    border-bottom: 1px solid #1f2940;
    max-height: 42vh;
  }

  .series-hero {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .series-hero img {
    width: 110px;
  }

  #seriesVideo {
    height: 36vh;
  }
}
