:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151515;
  --panel-2: #202020;
  --line: #303030;
  --text: #f7f3ec;
  --muted: #b7aea0;
  --dim: #756f66;
  --green: #27c178;
  --red: #d84a3a;
  --gold: #d8a545;
  --focus: #62b6ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(216, 74, 58, 0.08), transparent 24rem),
    linear-gradient(115deg, transparent 0 62%, rgba(39, 193, 120, 0.12) 62% 76%, transparent 76%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
a {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 9, 0.86);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.8rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(247, 243, 236, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--green) 0 30%, #fff 30% 68%, var(--red) 68%),
    var(--panel);
  color: #101010;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  letter-spacing: 0;
}

.brand p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(98, 182, 255, 0.7);
  outline: none;
}

.icon-button[aria-disabled="true"] {
  color: var(--dim);
  pointer-events: none;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(22rem, 29vw);
  min-height: 0;
}

.viewer {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  background: #030303;
}

.player-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(216, 165, 69, 0.08), transparent 40%),
    #000;
}

.player-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 9rem);
}

#player {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
}

.empty-state {
  position: absolute;
  inset: auto;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  max-width: min(28rem, calc(100% - 2rem));
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 21, 21, 0.92);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state span:last-child {
  color: var(--muted);
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0.35rem rgba(216, 74, 58, 0.18);
}

.now-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  min-height: 6.6rem;
  padding: 1rem clamp(1rem, 3vw, 1.6rem);
  border-top: 1px solid var(--line);
  background: rgba(9, 9, 9, 0.96);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.now-strip h2 {
  display: -webkit-box;
  max-width: 74ch;
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.15rem, 2.5vw, 1.8rem);
  letter-spacing: 0;
  line-height: 1.16;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.now-strip p:last-child {
  margin: 0.36rem 0 0;
  color: var(--muted);
}

.program-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 9rem;
}

.program-stats span,
.rail-heading span {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.rail {
  display: grid;
  grid-template-rows: minmax(9rem, 32%) minmax(0, 1fr);
  min-height: 0;
  border-left: 1px solid var(--line);
  background: rgba(18, 18, 18, 0.98);
}

.rail-section {
  min-height: 0;
  overflow: hidden;
  padding: 1rem;
}

.rail-section + .rail-section {
  border-top: 1px solid var(--line);
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.rail-heading h2 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0;
}

.program-list {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  height: calc(100% - 2.5rem);
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  scrollbar-color: var(--line) transparent;
}

.program-card {
  display: grid;
  grid-template-columns: 5.8rem minmax(0, 1fr);
  gap: 0.7rem;
  width: 100%;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  text-align: left;
}

button.program-card {
  cursor: pointer;
}

button.program-card:hover,
button.program-card:focus-visible,
.program-card.is-active {
  border-color: rgba(39, 193, 120, 0.72);
  outline: none;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--panel-2);
}

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

.program-card strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.program-card p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.program-card time,
.live-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 0.45rem;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 700;
}

.live-badge {
  color: var(--green);
}

.list-empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.ticker {
  min-height: 2.2rem;
  padding: 0.55rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--line);
  background: #050505;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    overflow: visible;
  }

  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(24rem, 62vh) minmax(18rem, 38vh);
  }

  .rail {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .rail-section + .rail-section {
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar,
  .now-strip {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .stage {
    grid-template-rows: minmax(23rem, 58vh) auto;
  }

  .rail {
    grid-template-columns: 1fr;
  }

  .rail-section {
    max-height: 22rem;
  }

  .rail-section + .rail-section {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .program-card {
    grid-template-columns: 4.8rem minmax(0, 1fr);
  }
}
