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

:root {
  --bg: #050505;
  --panel: rgba(17, 14, 28, 0.92);
  --panel-soft: rgba(32, 26, 54, 0.78);
  --line: rgba(126, 225, 47, 0.22);
  --purple: #9a36d2;
  --purple-strong: #b347ec;
  --green: #7ee12f;
  --green-soft: rgba(126, 225, 47, 0.16);
  --text: #f2f0f7;
  --muted: #a9a1b8;
  --info: #9ed7ff;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 8%, rgba(154, 54, 210, 0.34), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(126, 225, 47, 0.13), transparent 25%),
    linear-gradient(135deg, #030303 0%, #110b1c 48%, #071007 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  user-select: none;
}

.header {
  background: rgba(5, 5, 5, 0.88);
  border-bottom: 1px solid rgba(154, 54, 210, 0.55);
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
}

.header-content {
  width: min(1800px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.logo {
  display: flex;
  align-items: center;
}

.logo-image {
  width: clamp(160px, 18vw, 245px);
  height: 64px;
  object-fit: contain;
  display: block;
}

.header-controls {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box,
.input-field,
.category-filter {
  color: var(--text);
  background: rgba(20, 17, 33, 0.92);
  border: 1px solid rgba(126, 225, 47, 0.46);
  border-radius: 6px;
  outline: none;
}

.search-box {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
}

.search-box:focus,
.input-field:focus,
.category-filter:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(126, 225, 47, 0.18);
}

.settings-btn,
.settings-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(126, 225, 47, 0.35);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--purple), #6f24aa);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
}

.settings-btn:hover,
.settings-close:hover {
  background: linear-gradient(135deg, var(--purple-strong), var(--purple));
}

.container {
  width: min(1800px, 100%);
  min-height: calc(100vh - 82px);
  margin: 0 auto;
  padding: 14px;
  display: grid;
  grid-template-columns: 170px 390px minmax(0, 1fr);
  grid-template-areas: "sidebar channels player";
  gap: 12px;
}

.sidebar {
  grid-area: sidebar;
  min-height: calc(100vh - 110px);
  background: linear-gradient(180deg, rgba(20, 16, 34, 0.96), rgba(6, 6, 8, 0.92));
  border: 1px solid rgba(154, 54, 210, 0.42);
  border-radius: 8px;
  padding: 10px;
}

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

.tab-button {
  min-height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #d8d1e5;
  cursor: pointer;
  text-align: left;
}

.tab-button:hover {
  background: rgba(126, 225, 47, 0.08);
  border-color: rgba(126, 225, 47, 0.24);
}

.tab-button.active {
  background: linear-gradient(90deg, rgba(154, 54, 210, 0.72), rgba(126, 225, 47, 0.13));
  border-color: rgba(126, 225, 47, 0.58);
  color: #fff;
}

.tab-icon {
  width: 22px;
  color: var(--green);
  text-align: center;
}

.channels-section {
  grid-area: channels;
  min-height: calc(100vh - 110px);
  max-height: calc(100vh - 110px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.channels-header {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid rgba(126, 225, 47, 0.18);
}

.channels-header h2 {
  color: var(--green);
  font-size: 17px;
}

.channels-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.category-filter {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.category-filter option {
  background: #171221;
  color: var(--text);
}

.channel-count {
  min-width: 54px;
  text-align: center;
  padding: 8px 9px;
  border-radius: 6px;
  background: rgba(154, 54, 210, 0.78);
  color: #fff;
  font-size: 12px;
}

.channels-grid {
  list-style: none;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channels-grid.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  align-content: start;
  gap: 12px;
  padding: 12px;
}

.channel-item {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(126, 225, 47, 0.14);
  border-radius: 6px;
  background: rgba(36, 29, 58, 0.56);
  color: var(--text);
  cursor: pointer;
}

.channel-thumb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(126, 225, 47, 0.2);
  border-radius: 5px;
  background: rgba(5, 5, 5, 0.56);
  color: var(--green);
  font-size: 17px;
  font-weight: 800;
}

.channel-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.logo-thumb {
  width: 48px;
  height: 36px;
}

.logo-thumb img {
  object-fit: contain;
  padding: 4px;
}

.poster-thumb {
  width: 42px;
  height: 58px;
}

.channel-thumb.missing {
  background: linear-gradient(135deg, rgba(154, 54, 210, 0.44), rgba(126, 225, 47, 0.1));
}

.poster-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(126, 225, 47, 0.14);
  border-radius: 8px;
  background: rgba(36, 29, 58, 0.52);
  cursor: pointer;
}

.poster-card:hover {
  background: rgba(126, 225, 47, 0.1);
  border-color: rgba(126, 225, 47, 0.48);
}

.poster-art {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(154, 54, 210, 0.44), rgba(126, 225, 47, 0.1));
  color: var(--green);
  font-size: 26px;
  font-weight: 900;
}

.poster-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-title {
  color: #fff;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poster-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item:hover {
  background: rgba(126, 225, 47, 0.1);
  border-color: rgba(126, 225, 47, 0.48);
}

.search-group-header {
  padding: 12px 10px 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.channel-item span {
  min-width: 0;
  flex: 1;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.episode-item {
  align-items: flex-start;
}

.episode-item span {
  display: block;
  padding-top: 2px;
  line-height: 1.3;
}

.fav-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: rgba(126, 225, 47, 0.1);
  color: var(--green);
  cursor: pointer;
}

.fav-btn:hover {
  background: rgba(126, 225, 47, 0.22);
}

.load-more-item {
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
}

.load-more-item:hover {
  background: transparent;
  border-color: transparent;
}

.player-section {
  grid-area: player;
  min-height: calc(100vh - 110px);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-bottom: 1px solid rgba(154, 54, 210, 0.38);
}

.video-container video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

.player-info {
  padding: 16px;
  background: linear-gradient(180deg, rgba(18, 14, 29, 0.98), rgba(5, 5, 5, 0.96));
}

.player-info h2 {
  color: var(--green);
  font-size: 20px;
  margin-bottom: 8px;
}

.player-info p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.status-message {
  color: var(--info);
  background: rgba(10, 29, 58, 0.42);
  border-left: 3px solid var(--info);
  border-radius: 5px;
  padding: 9px 10px;
  font-size: 12px;
}

.media-description {
  color: #d7d0e2;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.media-facts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.media-facts p {
  color: #bfb7cc;
  font-size: 12px;
  margin: 0;
}

.media-action {
  max-width: 190px;
}

.tv-guide {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(126, 225, 47, 0.22);
}

.tv-guide-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tv-guide-header h3 {
  color: var(--green);
  font-size: 14px;
  text-transform: uppercase;
}

.guide-channel {
  color: var(--info);
  font-size: 12px;
  text-align: right;
}

.guide-listings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-listing {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(126, 225, 47, 0.14);
  border-radius: 6px;
  background: rgba(36, 29, 58, 0.52);
}

.guide-listing.empty {
  display: block;
  color: var(--info);
  font-size: 12px;
}

.guide-time {
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}

.guide-content strong {
  display: block;
  color: #fff;
  font-size: 13px;
  margin-bottom: 4px;
}

.guide-content p {
  color: #c8c1d2;
  font-size: 12px;
  line-height: 1.35;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.settings-overlay[hidden] {
  display: none;
}

.settings-panel {
  width: min(430px, 100%);
  height: 100%;
  padding: 22px;
  background: linear-gradient(180deg, #171021, #060606);
  border-left: 1px solid rgba(126, 225, 47, 0.35);
  box-shadow: -18px 0 45px rgba(0, 0, 0, 0.44);
  overflow-y: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.settings-header h2 {
  color: var(--green);
  font-size: 22px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-section h3 {
  color: var(--green);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.input-field {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  font-size: 13px;
}

select.input-field {
  cursor: pointer;
}

select.input-field option {
  background: #171221;
  color: var(--text);
}

.control-btn {
  width: 100%;
  min-height: 42px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--purple), #6f24aa);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.control-btn:hover {
  background: linear-gradient(135deg, var(--purple-strong), var(--purple));
}

.control-btn.secondary {
  background: rgba(126, 225, 47, 0.14);
  color: var(--green);
  border: 1px solid rgba(126, 225, 47, 0.62);
}

.control-btn.secondary:hover {
  background: rgba(126, 225, 47, 0.24);
}

.separator {
  height: 1px;
  margin: 18px 0;
  background: rgba(126, 225, 47, 0.2);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

::-webkit-scrollbar-thumb {
  background: var(--purple);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--purple-strong);
}

@media (max-width: 1180px) {
  .container {
    grid-template-columns: 150px minmax(300px, 0.8fr) minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "channels"
      "player";
  }

  .sidebar,
  .channels-section,
  .player-section {
    min-height: auto;
    max-height: none;
  }

  .tabs {
    flex-direction: row;
    overflow-x: auto;
  }

  .tab-button {
    flex: 0 0 auto;
    width: auto;
  }
}

@media (max-width: 620px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .logo {
    justify-content: center;
  }

  .logo-image {
    width: 220px;
    height: 76px;
  }

  .channels-tools {
    grid-template-columns: 1fr;
  }

  .channel-count {
    width: 100%;
  }

  .guide-listing {
    grid-template-columns: 1fr;
  }
}
