:root {
  --tv-black: #050504;
  --tv-ink: #0b0a09;
  --tv-panel: #11100e;
  --tv-panel-high: #171512;
  --tv-bone: #eee8dc;
  --tv-muted: #9d978c;
  --tv-faint: #5f5a52;
  --tv-line: #34312c;
  --tv-oxblood: #821421;
  --tv-red: #c42636;
  --tv-electric: #7db9b6;
  --tv-mono: "IBM Plex Mono", "Courier New", monospace;
  --tv-sans: "Space Grotesk", Arial, sans-serif;
}

body.ng-page--tv {
  min-width: 0;
  color: var(--tv-bone);
  background:
    radial-gradient(ellipse at 78% 12%, rgba(130, 20, 33, 0.14), transparent 31rem),
    linear-gradient(118deg, transparent 0 64%, rgba(125, 185, 182, 0.025) 64.1% 64.4%, transparent 64.5%),
    var(--tv-black) !important;
  font-family: var(--tv-sans) !important;
}

body.ng-page--tv::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 86px 0 0;
  opacity: 0.22 !important;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(238, 232, 220, 0.045) 50%, transparent 50.1%),
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(238, 232, 220, 0.025) 48px);
}

body.ng-page--tv::after {
  content: "TELEVISION IS A HOLE IN THE ROOM";
  position: fixed;
  z-index: 0;
  right: -1.5rem;
  bottom: 2rem;
  opacity: 0.05 !important;
  color: var(--tv-bone);
  font: 700 clamp(2.4rem, 7vw, 7rem)/0.82 Arial, sans-serif;
  letter-spacing: -0.08em;
  text-align: right;
  pointer-events: none;
  transform: rotate(-90deg) translateX(100%);
  transform-origin: right bottom;
}

body.ng-page--tv button,
body.ng-page--tv input {
  font: inherit;
}

body.ng-page--tv button {
  cursor: pointer;
}

body.ng-page--tv .ng-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

body.ng-page--tv .ng-brand__mark {
  width: 30px;
  height: 30px;
}

body.ng-page--tv .ng-brand > span {
  color: var(--tv-bone);
  font-style: normal;
}

body.ng-page--tv .ng-brand em {
  color: var(--tv-red);
  font-style: normal;
}

body.ng-page--tv h1,
body.ng-page--tv h2,
body.ng-page--tv p {
  margin: 0;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 64px));
  margin: clamp(28px, 4vw, 64px) auto 60px !important;
}

.tv-shell {
  display: grid;
  min-width: 0;
  gap: clamp(20px, 3vw, 38px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 30px;
  align-items: end;
  min-width: 0;
  padding: 0 0 24px;
  border: 0 !important;
  border-bottom: 1px solid var(--tv-line) !important;
  background: transparent !important;
}

.brand-lockup {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.eyebrow,
.section-kicker,
.section-label,
.live-pill,
.hud-row,
.deck-button,
.ghost-action,
.volume-control,
.search-box,
.result-summary,
.status-pill,
.deep-cuts-link {
  font-family: var(--tv-mono);
}

.eyebrow,
.section-kicker,
.section-label {
  color: var(--tv-muted);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

body.ng-page--tv h1 {
  max-width: 100%;
  color: var(--tv-bone);
  font: 700 clamp(4.5rem, 11vw, 10rem)/0.72 Arial, sans-serif !important;
  letter-spacing: -0.08em !important;
  overflow-wrap: anywhere;
}

.brand-copy {
  max-width: 48rem;
  color: var(--tv-muted);
  font-size: clamp(0.92rem, 1.3vw, 1.08rem);
  line-height: 1.65;
}

.live-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 15px 18px;
  border: 1px solid var(--tv-line) !important;
  background: rgba(17, 16, 14, 0.88) !important;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tv-red) !important;
  box-shadow: 0 0 18px rgba(196, 38, 54, 0.35) !important;
}

.live-pill__body {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.live-pill__label {
  color: var(--tv-faint);
  font-size: 0.6rem;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.live-pill__copy {
  color: var(--tv-bone);
  font-size: 0.7rem;
  line-height: 1.4;
}

.bezel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--tv-line) !important;
  background: var(--tv-panel) !important;
}

.screen-stage {
  position: relative;
  min-width: 0;
  background: #010101;
}

.screen {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 44%, rgba(125, 185, 182, 0.08), transparent 38%),
    #010101;
}

.screen::before {
  content: "";
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, rgba(130, 20, 33, 0.1), transparent 44%, rgba(125, 185, 182, 0.04));
  mix-blend-mode: screen;
}

.screen-video {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  background: #000;
  filter: saturate(0.82) contrast(1.04);
  transition: opacity 240ms ease;
}

.screen-video.is-visible {
  opacity: 1;
}

.boot-panel {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--tv-muted);
  font-family: var(--tv-mono);
  text-align: center;
  transition: opacity 180ms ease;
}

.boot-panel::before {
  content: "+";
  margin-bottom: 8px;
  color: var(--tv-oxblood);
  font-size: 2rem;
}

.boot-panel p {
  color: var(--tv-bone);
  font-size: clamp(0.8rem, 1.8vw, 1.1rem);
  letter-spacing: 0.22em;
}

.boot-panel span {
  font-size: clamp(0.62rem, 1.4vw, 0.78rem);
}

.boot-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.broadcast-bug {
  position: absolute;
  z-index: 7;
  top: clamp(12px, 2vw, 26px);
  right: clamp(12px, 2vw, 26px);
  width: clamp(38px, 4vw, 58px);
  opacity: 0.7;
}

.broadcast-bug__image {
  display: block;
  width: 100%;
  height: auto;
}

.hud {
  position: absolute;
  z-index: 7;
  right: clamp(12px, 2vw, 24px);
  bottom: clamp(12px, 2vw, 24px);
  left: clamp(12px, 2vw, 24px);
  display: grid;
  gap: 8px;
  color: rgba(238, 232, 220, 0.82);
  text-shadow: 0 1px 3px #000;
}

.hud-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: end;
  min-width: 0;
  font-size: clamp(0.52rem, 1vw, 0.72rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-row--bottom {
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  padding-top: 8px;
  border-top: 1px solid rgba(238, 232, 220, 0.24);
}

.hud-row--bottom span:last-child {
  text-align: right;
}

.screen-scanlines,
.screen-vignette,
.screen-static {
  position: absolute;
  z-index: 6;
  inset: 0;
  pointer-events: none;
}

.screen-scanlines {
  opacity: 0.14;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, 0.48) 4px);
}

.screen-vignette {
  box-shadow: inset 0 0 10vw rgba(0, 0, 0, 0.76);
}

.screen-static {
  opacity: 0;
  background:
    repeating-radial-gradient(circle at 20% 30%, rgba(255,255,255,.2) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(92deg, transparent 0 7px, rgba(255,255,255,.13) 8px, transparent 9px 14px),
    #0d0d0c;
  transition: opacity 110ms steps(2, end);
}

.screen.is-switching .screen-static {
  opacity: 0.62;
}

.library-drawer {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, auto) minmax(0, 1fr);
  gap: 16px;
  width: min(470px, 100%);
  min-width: 0;
  padding: clamp(18px, 2.5vw, 30px);
  overflow: auto;
  border: 0 !important;
  border-left: 1px solid var(--tv-line) !important;
  background: rgba(11, 10, 9, 0.97) !important;
  opacity: 0;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 220ms ease, opacity 180ms ease, visibility 220ms;
}

.library-drawer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.drawer-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.drawer-head > div,
.section-head > div {
  display: grid;
  gap: 7px;
}

.drawer-head h2,
.section-head h2 {
  color: var(--tv-bone);
  font: 700 clamp(1.5rem, 3vw, 2.35rem)/1 Arial, sans-serif !important;
  letter-spacing: -0.045em !important;
}

.ghost-action,
.deck-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--tv-line) !important;
  background: var(--tv-panel-high) !important;
  color: var(--tv-bone) !important;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.ghost-action:hover,
.ghost-action:focus-visible,
.deck-button:hover,
.deck-button:focus-visible {
  border-color: var(--tv-bone) !important;
  background: var(--tv-bone) !important;
  color: var(--tv-ink) !important;
  outline: none;
}

.deck-button--toggle {
  border-color: var(--tv-oxblood) !important;
  background: var(--tv-oxblood) !important;
}

.drawer-search {
  display: grid;
  gap: 10px;
}

.search-box {
  display: grid;
  gap: 7px;
  border: 0 !important;
  background: transparent !important;
}

.search-box span {
  color: var(--tv-muted);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--tv-line);
  outline: 0;
  background: #080807;
  color: var(--tv-bone);
  font-family: var(--tv-mono);
}

.search-box input:focus {
  border-color: var(--tv-electric);
}

.search-box input::placeholder {
  color: var(--tv-faint);
}

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

.drawer-actions > * {
  flex: 1;
}

.result-summary {
  min-height: 1em;
  color: var(--tv-faint);
  font-size: 0.64rem;
  line-height: 1.5;
}

.drawer-section {
  display: grid;
  align-content: start;
  min-height: 0;
  gap: 9px;
}

.channel-list,
.search-results {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.channel-button,
.search-card {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 5px;
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--tv-line);
  background: #0c0b0a;
  color: var(--tv-bone);
  font-family: var(--tv-mono);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.channel-button::before,
.search-card::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 2px;
  background: transparent;
}

.channel-button strong,
.search-card strong {
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-button span,
.search-card span,
.search-card em {
  overflow: hidden;
  color: var(--tv-faint);
  font-size: 0.58rem;
  font-style: normal;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.channel-button:hover,
.channel-button:focus-visible,
.search-card:hover,
.search-card:focus-visible {
  border-color: var(--tv-muted);
  background: var(--tv-panel-high);
  outline: none;
}

.channel-button.is-active {
  border-color: rgba(196, 38, 54, 0.55);
  background: rgba(130, 20, 33, 0.12);
}

.channel-button.is-active::before {
  background: var(--tv-red);
}

.channel-button.is-external::after {
  content: "↗";
  position: absolute;
  top: 12px;
  right: 14px;
  color: var(--tv-electric);
}

.search-empty,
.empty-card {
  padding: 16px;
  border: 1px dashed var(--tv-line);
  color: var(--tv-faint);
  font: 0.68rem/1.6 var(--tv-mono);
}

.deck {
  border-top: 1px solid var(--tv-line);
  background: var(--tv-ink);
}

.control-rack {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 250px);
  gap: 18px;
  align-items: center;
  min-width: 0;
  padding: 15px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.controls .deck-button {
  flex: 1 1 auto;
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  color: var(--tv-muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.volume-control input {
  width: 100%;
  min-width: 0;
  accent-color: var(--tv-oxblood);
}

.content-hub {
  display: grid;
  min-width: 0;
  gap: 18px;
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid var(--tv-line) !important;
  background: rgba(17, 16, 14, 0.82) !important;
}

.status-pill {
  flex: none;
  color: var(--tv-muted);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.epg-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.epg-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  min-width: 0;
  min-height: 112px;
  padding: 13px;
  border: 1px solid var(--tv-line);
  background: #0c0b0a;
  color: var(--tv-bone);
  font-family: var(--tv-mono);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.epg-card:hover,
.epg-card:focus-visible {
  border-color: var(--tv-muted);
  background: var(--tv-panel-high);
  outline: none;
}

.epg-card.is-active {
  border-color: rgba(196, 38, 54, 0.65);
}

.epg-thumb {
  grid-row: 1 / 4;
  display: grid;
  place-items: center;
  min-height: 72px;
  border: 1px solid var(--tv-line);
  color: var(--tv-red);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.epg-card strong,
.epg-card > span:not(.epg-thumb),
.epg-card em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.epg-card strong {
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
}

.epg-card > span:not(.epg-thumb),
.epg-card em {
  color: var(--tv-faint);
  font-size: 0.55rem;
  font-style: normal;
  line-height: 1.3;
  text-transform: uppercase;
}

.deep-cuts-link {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--tv-line);
  color: var(--tv-faint);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.deep-cuts-link a {
  color: var(--tv-bone);
  text-decoration: none;
}

.deep-cuts-link a:hover,
.deep-cuts-link a:focus-visible {
  color: var(--tv-electric);
  outline: none;
}

.screen:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  background: #000;
}

@media (max-width: 1100px) {
  .epg-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-rack {
    grid-template-columns: 1fr;
  }

  .volume-control {
    max-width: 360px;
  }
}

@media (max-width: 760px) {
  .layout {
    width: min(100% - 28px, 1480px);
    margin-top: 24px !important;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  body.ng-page--tv h1 {
    font-size: clamp(3.75rem, 19vw, 7rem) !important;
  }

  .brand-copy {
    max-width: 34rem;
  }

  .live-pill {
    width: 100%;
  }

  .screen {
    min-height: 300px;
    aspect-ratio: 4 / 3;
  }

  .control-rack {
    padding: 10px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls .deck-button {
    min-width: 0;
    padding-inline: 8px;
  }

  .library-drawer {
    width: 100%;
    border-left: 0 !important;
  }

  .epg-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .deep-cuts-link {
    display: grid;
  }
}

@media (max-width: 460px) {
  .layout {
    width: calc(100% - 20px);
    margin-bottom: 36px !important;
  }

  .topbar {
    padding-bottom: 18px;
  }

  body.ng-page--tv h1 {
    font-size: clamp(2.8rem, 14.8vw, 3.65rem) !important;
    letter-spacing: -0.075em !important;
  }

  .brand-copy {
    font-size: 0.86rem;
  }

  .screen {
    min-height: 238px;
  }

  .hud-row {
    grid-template-columns: auto 1fr;
  }

  .hud-row > span:last-child {
    display: none;
  }

  .hud-row--bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .hud-row--bottom span:last-child {
    display: block;
    text-align: left;
  }

  .broadcast-bug {
    width: 36px;
  }

  .drawer-head,
  .section-head {
    align-items: start;
  }

  .library-drawer {
    padding: 16px;
  }

  .content-hub {
    padding: 16px;
  }

  .epg-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-video,
  .screen-static,
  .library-drawer {
    transition: none;
  }
}
