.livetv-frame {
  width: min(100%, 88rem);
  margin-inline: auto;
  padding-inline: max(clamp(12px, 3vw, 36px), env(safe-area-inset-left))
    max(clamp(12px, 3vw, 36px), env(safe-area-inset-right));
}

.livetv-header {
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid #242424;
}

.livetv-header-inner {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.livetv-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text-bright);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.035em;
  text-decoration: none;
  white-space: nowrap;
}

.livetv-brand img {
  object-fit: contain;
}

.livetv-brand span span {
  color: var(--brand);
}

.livetv-nav {
  display: flex;
  gap: 4px;
}

.livetv-nav a {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding-inline: 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}

.livetv-nav a[aria-current="page"] {
  color: var(--text-bright);
  background: var(--bg-card);
}

.livetv-main {
  --guide-surface: #171717;
  --guide-raised: #242424;
  --guide-border: #303030;
  --guide-muted: #aaa;
  color-scheme: dark;
  padding-block: clamp(16px, 3vw, 28px) 24px;
}

.livetv-main [hidden] {
  display: none !important;
}

.livetv-page-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 12px;
}

.livetv-page-heading h1 {
  color: var(--text-bright);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -.04em;
}

#channelCount {
  color: var(--guide-muted);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}

.livetv-workspace {
  display: grid;
  gap: 14px;
  align-items: start;
}

.livetv-guide,
.livetv-player-section {
  min-width: 0;
}

.livetv-guide-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10.5rem, 32%);
  gap: 8px;
  max-width: 34rem;
  margin-bottom: 10px;
}

.livetv-search,
.livetv-category {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  border: 1px solid var(--guide-border);
  border-radius: 8px;
  background: var(--guide-surface);
}

.livetv-search svg,
.livetv-category svg {
  position: absolute;
  color: var(--guide-muted);
  pointer-events: none;
}

.livetv-search svg {
  left: 10px;
}

.livetv-category svg {
  right: 10px;
}

#liveTvSearchInput,
#categoryFilter {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
}

#liveTvSearchInput {
  padding: 0 8px 0 35px;
}

#liveTvSearchInput::placeholder {
  color: var(--guide-muted);
}

#categoryFilter {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 28px 0 10px;
  font-weight: 550;
  text-overflow: ellipsis;
  cursor: pointer;
}

#categoryFilter option {
  background: var(--guide-surface);
  color: var(--text-bright);
}

.livetv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 6px;
}

.channel-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 59px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--guide-surface);
  color: var(--text-bright);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.channel-card[aria-pressed="true"] {
  border-color: var(--guide-border);
  border-inline-start: 2px solid var(--brand);
  padding-inline-start: 8px;
  background: var(--guide-raised);
}

.channel-logo-wrap {
  display: grid;
  width: 100%;
  height: 37px;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: #272727;
}

.channel-logo {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 4px;
  background: #d7d5d2;
  object-fit: contain;
}

.channel-logo-fallback {
  color: #e5e5e5;
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .03em;
}

.channel-logo-dark {
  background: #202023;
}

.channel-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.channel-name {
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.channel-group {
  color: var(--guide-muted);
  font-size: .75rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.channel-chevron {
  color: var(--guide-muted);
}

.channel-card[aria-pressed="true"] .channel-chevron {
  color: var(--text-bright);
}

.livetv-guide-state {
  display: grid;
  min-height: 96px;
  justify-items: start;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid #242424;
  border-radius: 8px;
  color: var(--guide-muted);
  font-size: .875rem;
}

.livetv-icon-btn,
.livetv-text-btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--guide-raised);
  color: var(--text-bright);
  font: 600 .8125rem 'Inter', system-ui, sans-serif;
  cursor: pointer;
}

.livetv-text-btn {
  padding-inline: 12px;
}

.livetv-load-more {
  margin-top: 8px;
}

.livetv-icon-btn {
  width: 44px;
  background: transparent;
}

.livetv-player-section {
  padding: 6px;
  border: 1px solid #282828;
  border-radius: 10px;
  background: var(--guide-surface);
}

.livetv-player-header {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) repeat(2, 44px);
  align-items: center;
  gap: 5px;
  padding: 0 0 6px 4px;
}

.livetv-player-header .channel-logo-wrap {
  height: 32px;
}

.livetv-player-identity {
  min-width: 0;
  padding-inline: 3px;
}

#inlinePlayerTitle {
  color: var(--text-bright);
  font-size: clamp(.9375rem, 2vw, 1.125rem);
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#liveTvPlayerStatus,
.livetv-player-toast {
  color: var(--guide-muted);
  font-size: .75rem;
  line-height: 1.35;
}

#liveTvPlayerStatus[data-state="live"]::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-end: 5px;
  border-radius: 50%;
  background: var(--brand);
  vertical-align: .1em;
  content: "";
}

.livetv-player-toast {
  padding: 8px 4px 2px;
}

.livetv-video {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
}

#liveVideoPlayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#liveYouTubeContainer {
  min-height: 200px;
}

#liveYouTubeContainer iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.livetv-radio {
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: #111;
}

.livetv-radio-art {
  display: grid;
  min-height: 0;
  justify-items: center;
  gap: 8px;
}

.livetv-radio-logo {
  display: grid;
  width: clamp(48px, 8dvh, 112px);
  height: clamp(48px, 8dvh, 112px);
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #272727;
}

.livetv-radio-art p {
  color: var(--guide-muted);
  font-size: .8125rem;
}

.livetv-radio-logo .channel-logo-fallback {
  font-size: clamp(1rem, 3dvh, 1.75rem);
}

#liveRadioPlayer {
  flex: none;
  width: min(100%, 280px);
  height: 44px;
  color-scheme: dark;
}

#liveRadioPlayer::-webkit-media-controls-timeline,
#liveRadioPlayer::-webkit-media-controls-current-time-display,
#liveRadioPlayer::-webkit-media-controls-time-remaining-display {
  display: none;
}

.livetv-frame :focus-visible {
  outline: 2px solid #eee;
  outline-offset: -2px;
}

@media (hover: hover) {
  .channel-card:hover,
  .livetv-nav a:hover,
  .livetv-icon-btn:hover {
    background: var(--guide-raised, #242424);
  }
}

@media (max-width: 768px) {
  .livetv-nav {
    display: none;
  }
}

@media (max-width: 360px) {
  .livetv-guide-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 1000px) {
  .livetv-radio-logo {
    width: clamp(80px, 14dvh, 144px);
    height: clamp(80px, 14dvh, 144px);
  }

  html:has(#liveTvWorkspace) {
    overflow: hidden;
    overscroll-behavior-y: none;
  }

  body:has(#liveTvWorkspace) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body:has(#liveTvWorkspace) > .livetv-header {
    flex: none;
  }

  body:has(#liveTvWorkspace) > .site-footer {
    display: none;
  }

  body:has(#liveTvWorkspace) .livetv-main {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding-block: 16px 20px;
  }

  .livetv-page-heading {
    flex: none;
  }

  .livetv-workspace {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .livetv-workspace.is-tuned {
    grid-template-columns: minmax(0, 1fr) clamp(19rem, 31vw, 24rem);
    gap: 16px;
  }

  .livetv-guide {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    padding-bottom: 12px;
    scroll-padding-block: 64px 12px;
  }

  .livetv-guide-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    margin-bottom: 0;
    padding-bottom: 10px;
    background: var(--bg);
  }

  .is-tuned .livetv-guide-toolbar {
    max-width: none;
  }

  .is-tuned .livetv-player-section {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .is-tuned .livetv-player-header,
  .is-tuned .livetv-player-toast {
    flex: none;
  }

  .is-tuned .livetv-video:not(:fullscreen) {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
  }

  .is-tuned #liveYouTubeContainer {
    min-height: 0;
  }
}

/* A tuned phone is a watch screen: the guide owns the scroll, not the player. */
@media (max-width: 999px) {
  html:has(#liveTvWorkspace.is-tuned) {
    overflow: hidden;
    overscroll-behavior-y: none;
  }

  body:has(#liveTvWorkspace.is-tuned) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body:has(#liveTvWorkspace.is-tuned) > .livetv-header {
    flex: none;
  }

  body:has(#liveTvWorkspace.is-tuned) > .site-footer {
    display: none;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-main {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding-block: 10px 0;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-page-heading {
    flex: none;
    margin-bottom: 10px;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-page-heading h1 {
    font-size: 1.25rem;
  }

  .livetv-workspace.is-tuned {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
  }

  .is-tuned .livetv-guide {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
    scroll-padding-block: 56px calc(86px + env(safe-area-inset-bottom));
  }

  .is-tuned .livetv-guide-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    max-width: none;
    margin-bottom: 0;
    padding-bottom: 10px;
    background: var(--bg);
  }

  .is-tuned .livetv-video:not(:fullscreen) {
    max-height: 40vh;
    max-height: 40dvh;
  }

  .is-tuned #liveYouTubeContainer {
    min-height: 0;
  }

  .is-tuned #inlinePlayerTitle {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
}

@media (max-width: 999px) and (max-height: 650px) {
  body:has(#liveTvWorkspace.is-tuned) > .livetv-header {
    display: none;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-page-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-main {
    padding-top: max(8px, env(safe-area-inset-top));
  }
}

@media (min-width: 500px) and (max-width: 999px) and (max-height: 480px) and (orientation: landscape) {
  .livetv-header-inner {
    min-height: 44px;
  }

  .livetv-main {
    padding-block-start: 10px;
  }

  .livetv-page-heading {
    margin-bottom: 8px;
  }

  .livetv-workspace.is-tuned {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 39%);
    grid-template-rows: minmax(0, 1fr);
    gap: 10px;
  }

  body:has(#liveTvWorkspace.is-tuned) .livetv-main {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .is-tuned .livetv-player-section {
    align-self: start;
  }

  .is-tuned .livetv-guide {
    padding-bottom: 8px;
    scroll-padding-bottom: 8px;
  }

  .is-tuned .livetv-guide-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .is-tuned .livetv-video:not(:fullscreen) {
    max-height: max(96px, calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }

  body:has(.livetv-workspace.is-tuned) > .mobile-dock-wrapper {
    display: none;
  }
}
