:root {
  --bg: #0a100e;
  --bg-elevated: #101814;
  --panel: #0e1512;
  --line: rgba(212, 184, 130, 0.14);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #f2efe8;
  --muted: #8b958e;
  --gold: #d4b882;
  --gold-soft: #c4a574;
  --green: #3d7a5c;
  --green-soft: #2f5f48;
  --danger: #c45c5c;
  --font-display: "Syne", "Trebuchet MS", sans-serif;
  --font-body: "DM Sans", "Segoe UI", Candara, sans-serif;
  --radius: 4px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

button, input {
  font: inherit;
  color: inherit;
}

.bg-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(61, 122, 92, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(212, 184, 130, 0.07), transparent 50%),
    linear-gradient(180deg, #0c1411 0%, var(--bg) 40%, #080c0a 100%);
}

/* —— Topbar —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 16, 14, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  animation: brandIn 0.7s var(--ease) both;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  border-radius: var(--radius);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  padding: 0.4rem 0;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 0.35s var(--ease), color 0.35s var(--ease);
  border: 0;
  background: transparent;
}

.live-pill.on {
  opacity: 1;
  color: #e8a0a0;
}

.live-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  opacity: 0.5;
}

.live-pill.on i {
  opacity: 1;
  animation: pulse 1.6s ease-out infinite;
}

/* —— Layout —— */
.stage {
  width: min(1180px, calc(100% - 2.5rem));
  margin: 1.5rem auto 2rem;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 1.25rem;
  align-items: start;
  animation: stageIn 0.65s var(--ease) 0.08s both;
}

.player-panel,
.channel-panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

/* —— Player —— */
.player-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #050807;
  isolation: isolate;
}

.player-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 4;
}

.player-shell video,
.player-shell iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.player-shell video.is-hidden,
.player-shell iframe.is-hidden,
.player-empty.is-hidden,
.player-status.is-hidden {
  display: none !important;
}

.player-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  overflow: hidden;
  color: var(--muted);
  padding: 1.5rem;
}

.empty-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  animation: emptyDrift 18s ease-in-out infinite alternate;
}

.empty-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 10, 8, 0.35) 0%, rgba(6, 10, 8, 0.72) 55%, rgba(6, 10, 8, 0.92) 100%),
    radial-gradient(ellipse 55% 50% at 50% 40%, rgba(61, 122, 92, 0.18), transparent 65%);
}

.empty-copy {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  text-align: center;
  animation: brandIn 0.8s var(--ease) both;
}

.empty-logo {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  margin-bottom: 0.55rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: breathe 3.6s ease-in-out infinite;
}

.empty-brand {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.empty-hint {
  color: rgba(242, 239, 232, 0.78);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}

.player-status {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius);
  background: rgba(10, 16, 14, 0.92);
  border: 1px solid rgba(196, 92, 92, 0.3);
  color: #f0c8c8;
  font-size: 0.84rem;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease;
}

.file-banner {
  display: none;
  margin: 1rem 1.25rem 0;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(212, 184, 130, 0.28);
  background: rgba(212, 184, 130, 0.08);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.file-banner.show {
  display: block;
  animation: stageIn 0.4s var(--ease) both;
}

.file-banner code {
  font-size: 0.8rem;
  color: var(--gold);
}

.now-playing {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.15rem 1.35rem 1.3rem;
  border-top: 1px solid var(--line-soft);
}

.now-label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.now-playing h1 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.now-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--line-soft);
}

.chip.geo {
  color: #e8a8a8;
  border-color: rgba(196, 92, 92, 0.3);
  background: rgba(196, 92, 92, 0.1);
}

.chip.type-hls {
  color: #9dc4b0;
  border-color: rgba(61, 122, 92, 0.35);
  background: rgba(61, 122, 92, 0.12);
}

.chip.type-youtube {
  color: #e0c9a0;
  border-color: rgba(212, 184, 130, 0.35);
  background: rgba(212, 184, 130, 0.1);
}

/* —— Channel panel —— */
.channel-panel {
  display: flex;
  flex-direction: column;
  max-height: min(82vh, 780px);
}

.channel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.2rem 1.25rem 0.65rem;
  gap: 0.75rem;
}

.channel-kicker {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 0.2rem;
}

.channel-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.channel-head span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius);
}

.feature-rail {
  display: flex;
  gap: 0.55rem;
  padding: 0 1.15rem 0.85rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.feature-rail::-webkit-scrollbar {
  display: none;
}

.feature-card {
  flex: 0 0 78px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  isolation: isolate;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.feature-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease);
}

.feature-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(6, 10, 8, 0.92));
}

.feature-card span {
  position: absolute;
  left: 0.4rem;
  right: 0.4rem;
  bottom: 0.4rem;
  z-index: 1;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.feature-card:hover {
  transform: translateY(-2px);
}

.feature-card:hover img {
  transform: scale(1.06);
}

.feature-card.active {
  box-shadow: 0 0 0 1.5px var(--gold);
}

.search-wrap {
  position: relative;
  padding: 0 1.25rem 0.75rem;
}

.search-ico {
  position: absolute;
  left: calc(1.25rem + 0.85rem);
  top: 50%;
  transform: translateY(calc(-50% - 0.12rem));
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.7rem 0.5rem 0.7rem 2.35rem;
  border-radius: 0;
  outline: none;
  transition: border-color 0.25s var(--ease);
}

.search-wrap input:focus {
  border-bottom-color: var(--gold);
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0 0.75rem 0;
  margin: 0 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line-soft);
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  transition: color 0.2s var(--ease);
}

.filter::after {
  content: "";
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s var(--ease);
}

.filter:hover {
  color: var(--text);
}

.filter.active {
  color: var(--text);
}

.filter.active::after {
  transform: scaleX(1);
}

.channel-list {
  list-style: none;
  overflow-y: auto;
  padding: 0.75rem 0.65rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 184, 130, 0.28) transparent;
}

.channel-list::-webkit-scrollbar {
  width: 5px;
}

.channel-list::-webkit-scrollbar-thumb {
  background: rgba(212, 184, 130, 0.28);
  border-radius: 999px;
}

.channel-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 0;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  transition:
    background 0.22s var(--ease),
    border-color 0.22s var(--ease),
    color 0.22s var(--ease);
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.channel-item.active {
  background: rgba(212, 184, 130, 0.07);
  border-left-color: var(--gold);
}

.channel-thumb {
  width: 42px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #121a16;
  border: 1px solid var(--line-soft);
}

.channel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.channel-item.active .channel-thumb {
  border-color: rgba(212, 184, 130, 0.45);
}

.channel-info {
  min-width: 0;
}

.channel-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-info span {
  font-size: 0.7rem;
  color: var(--muted);
}

.channel-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
}

.channel-item.active .channel-tag {
  color: var(--gold);
  border-color: rgba(212, 184, 130, 0.3);
}

.channel-item.load-more {
  justify-content: center;
  color: var(--gold);
  font-weight: 600;
  grid-template-columns: 1fr;
  letter-spacing: 0.02em;
  border-left-color: transparent;
  margin-top: 0.35rem;
}

.channel-item.load-more:hover {
  background: rgba(212, 184, 130, 0.08);
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 0 1rem 2rem;
  opacity: 0.7;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(196, 92, 92, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(196, 92, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 92, 92, 0); }
}

@keyframes brandIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes stageIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes emptyDrift {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to { transform: scale(1.06) translate3d(-1.2%, -0.8%, 0); }
}

@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    width: min(100% - 1.5rem, 1180px);
  }

  .channel-panel {
    max-height: none;
  }

  .channel-list {
    max-height: 52vh;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 0.85rem 1rem;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-text strong {
    font-size: 1.2rem;
  }

  .brand-text span {
    display: none;
  }

  .now-playing {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.05rem 1.15rem;
  }

  .now-meta {
    justify-content: flex-start;
  }

  .stage {
    margin-top: 1rem;
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand,
  .stage,
  .empty-logo,
  .empty-bg,
  .live-pill.on i {
    animation: none;
  }
}
