:root {
  --page: #0b0e11;
  --surface: #edf1f4;
  --raised: #ffffff;
  --ink: #182026;
  --muted: #65717a;
  --line: #c5cdd3;
  --shell: #171c21;
  --panel: #20262c;
  --panel-soft: #2c343b;
  --panel-line: #4e5962;
  --panel-text: #f6f8f9;
  --panel-muted: #b8c1c8;
  --accent: #2879e8;
  --accent-hover: #1d68cc;
  --selection: #d7e7f8;
  --teal: #21a77d;
  --amber: #dda236;
  --danger: #d05149;
  --focus: #ffbd4a;
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-size: 14px;
}

.sidebar-actions { overflow-x: auto; scrollbar-width: none; }
.sidebar-actions > button { flex: 0 0 auto; }

* {
  box-sizing: border-box;
}

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

body {
  background: var(--page);
  color: var(--panel-text);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #8e99a2;
  border-radius: 4px;
  background: var(--raised);
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: default;
  opacity: 0.46;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex="0"]:focus-visible,
video:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Keep the focus ring visible inside scroll/clipping containers. */
.channel-row:focus-visible,
.sidebar-actions button:focus-visible { outline-offset: -3px; }

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.player-brand-surface {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #122638;
  background-image: radial-gradient(ellipse at 50% 30%, #244963 0%, #142c40 48%, #0d1c2c 100%);
  color: #f5f7f8;
  font-size: 16px;
  line-height: 1.4;
  padding: 24px 24px calc(var(--playback-action-bottom, 82px) + 110px);
}
.player-brand {
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 auto; gap: 12px; margin: 0;
}
.player-brand img { width: 64px; height: auto; }
.player-brand strong { font-size: 22px; line-height: 1.4; letter-spacing: .12em; }

.boot-view { position: relative; display: flex; height: 100%; }

.boot-message {
  position: absolute; left: 12px; bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  max-width: calc(100% - 24px); max-height: 40%; overflow: auto;
  padding: 6px 10px; border: 1px solid var(--panel-line); border-radius: 6px;
  background: rgb(24 29 34 / 96%); font-size: 14px;
  line-height: 1.5;
}
.boot-message span { overflow-wrap: anywhere; }
.boot-message button { min-height: 44px; }

.app-shell {
  --sidebar-gutter: 8px;
  --controls-height: 52px;
  --channel-row-height: 37px;
  --sidebar-footer-padding: 6px;
  --sidebar-footer-border: 1px;
  /* Reserve the actual sidebar target plus its border-box padding and border. */
  --sidebar-footer-minimum: calc(44px + 2 * var(--sidebar-footer-padding) + var(--sidebar-footer-border));
  --sidebar-footer-height: var(--sidebar-footer-minimum);
  --sidebar-search-height: 0px;
  --sidebar-button-size: 40px;
  --sidebar-width: 288px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 0;
  padding: 0;
  background: var(--page);
  isolation: isolate;
}

/* Custom properties accept unknown functions; guard max() before storing it. */
@supports (width: max(1px, 2px)) {
  .app-shell {
    --sidebar-footer-minimum: calc(max(44px, var(--sidebar-button-size)) + 2 * var(--sidebar-footer-padding) + var(--sidebar-footer-border));
  }
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 56px minmax(0, 1fr);
}

.channel-panel,
.player-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0;
}

.channel-panel {
  z-index: 12;
  border-right: 1px solid #39424a;
  border-radius: 8px;
  background: #101720;
  color: var(--panel-text);
}

.expanded-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 var(--sidebar-gutter);
}

.brand-bar {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.brand-identity {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  gap: 2px 8px;
}

.brand-identity img {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
}

.brand-identity strong {
  overflow: hidden;
  color: var(--panel-text);
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-identity span {
  flex-basis: 100%;
  align-self: center;
  color: var(--panel-muted);
  font-size: 11px;
  white-space: nowrap;
}

.brand-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

.icon-button,
.video-icon-button {
  border-radius: 8px;
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border-color: var(--panel-line);
  background: var(--panel);
  color: var(--panel-text);
  line-height: 1;
}

.ui-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-play,
.icon-pause {
  fill: currentColor;
  stroke: none;
}

[data-icon="play"] .icon-pause,
[data-icon="pause"] .icon-play,
[data-icon="volume"] .icon-muted,
[data-icon="muted"] .icon-volume,
[data-icon="maximize"] .icon-minimize,
[data-icon="minimize"] .icon-maximize {
  display: none;
}

.search-field {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  min-width: 0;
  align-items: center;
  gap: 2px;
  height: 44px;
  flex-shrink: 0;
  margin: 8px 0;
  padding: 0 10px;
  border: 1px solid #c2cad0;
  border-radius: 8px;
  background: #f8fafb;
  color: #66717a;
}

.search-field:focus-within {
  border-color: var(--accent);
}

.search-field .ui-icon {
  width: 18px;
  height: 18px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.list-footer .icon-button[aria-pressed="true"],
.list-footer .icon-button[aria-expanded="true"]:not(#sidebarCollapseButton) {
  border-color: #4a82d9;
  background: var(--accent);
  color: white;
}

.channel-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ecf2f8;
  scrollbar-gutter: stable;
}

.channel-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 19px 13px;
  min-height: var(--channel-row-height);
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(98, 140, 173, 0.16);
  color: inherit;
  cursor: pointer;
}

.channel-row:hover,
.channel-row[aria-selected="true"] {
  background: rgba(106, 166, 226, 0.24);
}

.channel-index {
  color: #5d6972;
  font-size: 12px;
  text-align: right;
}

.channel-name {
  min-width: 0;
  overflow: hidden;
  padding: 0 7px;
  font-size: 16px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Watching and expanded browsing share a bounded page of channel rows. */
.channel-browse-entry { display: flex; flex: 0 0 auto; padding: 6px 0 2px; }
.channel-browse-entry .quiet-button { width: auto; min-height: 38px; text-align: left; font-size: 14px; font-weight: 600; }
.channel-filter-bar { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; min-height: 32px; padding: 4px 0 6px; }
#channelFilterSummary { flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#channelClearFiltersButton { flex: 0 0 auto; min-height: 32px; padding: 4px 8px; }
.channel-browse-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); flex: 0 0 auto; gap: 10px; align-items: center; padding: 4px 0; }
.channel-browse-controls select { width: 100%; min-width: 0; min-height: 40px; border: 1px solid var(--panel-line); border-radius: 6px; padding: 6px 8px; background: var(--panel); color: var(--panel-text); font: inherit; }
select:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.channel-pagination { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; }
.channel-pagination .quiet-button { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 6px 9px; border-radius: 8px; }
.sidebar-actions { gap: 2px; }
.app-shell:not(.platform-tv) .sidebar-actions .icon-button,
.app-shell.platform-tv .sidebar-actions .icon-button { width: auto; min-width: 44px; min-height: 44px; padding: 4px; display: inline-flex; justify-content: center; }
.sidebar-action-label { font-size: 14px; line-height: 18px; white-space: nowrap; }
.app-shell.platform-tv .sidebar-actions .icon-button { min-width: 48px; min-height: 48px; }
.platform-tv .sidebar-action-label { font-size: 16px; line-height: 20px; }
.channel-browse-open .channel-browse-entry { order: 0; }
.channel-browse-open .channel-browse-controls { order: 1; }
.channel-browse-open .search-field { order: 2; margin: 4px 0; }
.channel-browse-open .channel-filter-bar { order: 3; }
.channel-browse-open .channel-list { order: 4; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(min(100%, max(200px, 25%)), 1fr)); align-content: start; }
.channel-browse-open .channel-row { min-width: 0; min-height: 48px; grid-template-columns: 34px minmax(0, 1fr) 32px 13px; border-right: 1px solid rgba(98, 140, 173, 0.16); }
.channel-browse-open .channel-list .empty-list { grid-column: 1 / -1; }
.channel-browse-open .channel-pagination { order: 5; }
.channel-browse-open .list-footer { order: 6; }
.channel-browse-open .favorite-button { width: 32px; min-width: 32px; min-height: 44px; }
.app-shell.channel-browse-open:not(.sidebar-collapsed) .channel-panel { height: 100%; max-height: 100%; align-self: stretch; }
@media (min-width: 1101px) {
  .app-shell.channel-browse-open:not(.platform-tv) { grid-template-columns: min(864px, 55vw) minmax(0, 1fr); }
}
@media (min-width: 700px) and (max-width: 1100px) and (orientation: landscape) {
  .app-shell.channel-browse-open:not(.platform-tv) { grid-template-columns: calc(55vw + env(safe-area-inset-left, 0px)) minmax(0, 1fr); }
}
.app-shell.platform-tv.channel-browse-open { grid-template-columns: 55vw minmax(0, 1fr); grid-template-columns: min(864px, 55vw) minmax(0, 1fr); }
.app-shell.platform-tv.channel-browse-open .channel-panel { position: relative; grid-column: 1; grid-row: 1; width: 100%; top: 0; bottom: 0; }
.app-shell.platform-tv.channel-browse-open .player-panel { grid-column: 2; }
.platform-tv.channel-browse-open .channel-row { min-height: 57px; grid-template-columns: 34px minmax(0, 1fr) 48px 13px; }
.platform-tv.channel-browse-open .favorite-button { width: 48px; min-width: 48px; min-height: 48px; }
html:not(.app-fullscreen-active) .platform-tv.channel-browse-open:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .video-controls { left: 0; }
@media (max-width: 1100px), (pointer: coarse) {
  .app-shell:not(.platform-tv) .channel-browse-entry .quiet-button,
  .app-shell:not(.platform-tv) #channelClearFiltersButton,
  .app-shell:not(.platform-tv) .channel-browse-controls select,
  .app-shell:not(.platform-tv) .channel-pagination .quiet-button { min-height: 44px; }
  .app-shell:not(.platform-tv).channel-browse-open .channel-row { grid-template-columns: 32px minmax(0, 1fr) 44px 13px; }
  .app-shell:not(.platform-tv).channel-browse-open .favorite-button { width: 44px; min-width: 44px; }
}

.favorite-button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #68747d;
  font-size: 16px;
}

.favorite-button.active {
  color: var(--amber);
}

.favorite-button.favorite-reminder {
  color: var(--amber);
  background-color: rgba(255, 213, 107, .18);
  animation: watch-favorite-reminder 1s steps(1, end) 5;
}

@keyframes watch-favorite-reminder {
  0%, 49% { color: var(--amber); background-color: rgba(255, 213, 107, .18); }
  50%, 100% { color: #68747d; background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .favorite-button.favorite-reminder { animation: none; }
}

.availability-dot,
.state-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #697680;
}

.availability-dot {
  justify-self: center;
}
.channel-row:not([aria-selected="true"]) .availability-dot { visibility: hidden; }

.availability-dot.ok,
.state-dot.ok {
  background: var(--teal);
}

.availability-dot.busy,
.state-dot.busy {
  background: var(--amber);
}

.availability-dot.error,
.state-dot.error {
  background: var(--danger);
}

.empty-list {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.list-footer {
  position: static;
  display: flex;
  flex-shrink: 0;
  min-height: var(--sidebar-footer-height);
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin: 0 calc(-1 * var(--sidebar-gutter));
  padding: var(--sidebar-footer-padding) var(--sidebar-gutter) calc(var(--sidebar-footer-padding) + env(safe-area-inset-bottom, 0px));
  border-top: var(--sidebar-footer-border) solid rgb(109 122 132 / 52%);
  color: var(--panel-muted);
  background: transparent;
  font-size: 11px;
}

.sidebar-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
}

.sidebar-more-panel {
  position: absolute;
  z-index: 2;
  right: var(--sidebar-gutter);
  bottom: calc(var(--sidebar-footer-height) + 6px);
  left: var(--sidebar-gutter);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: calc(100% - var(--sidebar-footer-height) - 12px);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: 0 6px 24px rgb(0 0 0 / 35%);
  font-size: 14px;
}

.sidebar-more-panel > :not(button),
.sidebar-more-panel #audioBalanceButton { grid-column: 1 / -1; }
.sidebar-more-panel .brand-bar { min-height: 28px; margin: 0; }
.sidebar-more-panel .brand-identity { gap: 2px 6px; }
.sidebar-more-panel .brand-identity img { width: 22px; height: 22px; flex-basis: 22px; }
.sidebar-more-panel .brand-identity strong { font-size: 15px; }
.sidebar-more-panel .brand-identity span { white-space: normal; overflow-wrap: anywhere; }
.player-language-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player-language-control select { min-width: 0; min-height: 36px; padding: 5px 7px; border: 1px solid #7c8992;
  border-radius: 6px; background: var(--panel); color: inherit; font: inherit; font-size: 13px; }
.sidebar-more-panel button { min-width: 0; min-height: 36px; padding: 5px 7px; font-size: 13px; justify-content: center; }
.sidebar-more-panel .install-button { white-space: normal; }
@media (pointer: coarse) { .sidebar-more-panel button, .player-language-control select { min-height: 44px; } }
.platform-tv .sidebar-more-panel button { min-height: 48px; font-size: 16px; }
.platform-tv .player-language-control select { min-height: 48px; font-size: 16px; }
.playback-diagnostics-dialog { width: min(480px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  top: 0; right: 0; bottom: 0; left: 0;
  top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px);
  inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  margin: auto; padding: 20px; overflow: auto; border: 1px solid var(--panel-line); border-radius: 12px;
  background: var(--panel); color: var(--panel-text); box-shadow: 0 16px 60px rgb(0 0 0 / 45%); }
.playback-diagnostics-dialog::backdrop { background: rgb(5 13 21 / 74%); }
.playback-diagnostics-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.playback-diagnostics-dialog form { margin: 12px 0 0; text-align: right; }
.playback-diagnostics-dialog button { min-height: 44px; min-width: 72px; padding: 8px 16px; }
.playback-diagnostics-status { margin: 0 0 12px; color: var(--panel-text); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.playback-diagnostics-status:empty { display: none; }
.playback-diagnostics-text { display: block; width: 100%; min-width: 0; max-height: min(180px, 35dvh); resize: vertical; padding: 8px;
  border: 1px solid var(--panel-line); border-radius: 6px; background: var(--panel); color: var(--panel-text); font-size: 12px; }
#channelCount { color: var(--panel-muted); font-size: 12px; }
#subscriptionExpiry { color: var(--panel-muted); font-size: 12px; overflow-wrap: anywhere; }

.collapsed-sidebar {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto;
  align-items: end;
  justify-items: center;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
}

.collapsed-label {
  display: none;
}

.player-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  background: var(--page);
  color: var(--panel-text);
}

.video-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  height: 100%;
  border-radius: 0;
  background: var(--page);
}

.video-surface { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; overflow: hidden; }

.content-recovery { display: none; }
.authorization-checking .content-recovery,
.content-protected .content-recovery,
.playback-waiting .content-recovery {
  display: flex; position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 4;
  pointer-events: none;
}
.content-recovery-message { max-width: 36rem; text-align: center; overflow-wrap: anywhere; }
.platform-tv .content-recovery-message { font-size: 20px; }
.content-recovery-detail { color: #c4d0d9; font-size: 14px; line-height: 1.4; text-align: center; }
.status-working { animation: status-color 3.6s ease-in-out infinite; }
@keyframes status-color {
  0%, 100% { color: #f5f7f8; }
  50% { color: #9bcaff; }
}
.authorization-checking .content-recovery { background: var(--page); }
.authorization-checking .loading-overlay,
.content-protected .loading-overlay,
.playback-waiting .loading-overlay { display: none !important; }

html.app-fullscreen-active,
html.app-fullscreen-active body {
  overflow: hidden;
}

.video-stage.app-fullscreen {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
}

.video-stage video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--page);
  object-fit: contain;
}

.embedded-browser-notice {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  z-index: 6;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 36px;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border: 1px solid #64717a;
  border-radius: 6px;
  background: rgb(19 23 27 / 96%);
  color: #f4f7f8;
  box-shadow: 0 7px 20px rgb(0 0 0 / 28%);
  pointer-events: none;
}

.embedded-browser-notice > .ui-icon {
  color: #54c7a1;
}

.embedded-browser-notice span {
  min-width: 0;
  line-height: 1.4;
}

.embedded-browser-notice button {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: inherit;
  pointer-events: auto;
}

.video-stage video::-webkit-media-controls,
.video-stage video::-webkit-media-controls-enclosure,
.video-stage video::-webkit-media-controls-overlay-enclosure {
  display: none !important;
}

.interstitial-layer {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 8;
  display: flex;
  overflow: hidden;
  color: #f7f9f8;
  letter-spacing: 0;
  pointer-events: none;
}

.interstitial-layer[hidden] {
  display: none;
}

.interstitial-layer.is-full-screen {
  align-items: stretch;
  justify-content: stretch;
  padding: 24px;
  background: #090c0e;
}

.interstitial-layer.is-corner {
  align-items: flex-start;
  justify-content: flex-end;
  padding: 16px;
  padding-bottom: 80px;
  background: transparent;
}

.interstitial-frame {
  min-width: 0;
  min-height: 0;
}

.interstitial-layer.is-full-screen .interstitial-frame {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: minmax(0, 3fr) minmax(220px, 2fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.interstitial-layer.is-corner .interstitial-frame {
  display: grid;
  width: min(420px, calc(100% - 8px));
  max-width: min(420px, calc(100% - 8px));
  max-height: calc(100% - 80px);
  grid-template-columns: 104px minmax(0, 1fr);
  grid-template-rows: minmax(0, auto) auto;
  gap: 12px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid #527065;
  border-radius: 6px;
  background: rgb(20 25 28 / 96%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 34%);
}

.interstitial-image {
  display: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

.interstitial-layer.has-image .interstitial-image:not([hidden]) {
  display: block;
}

.interstitial-layer.is-full-screen .interstitial-image {
  grid-column: 1;
  grid-row: 1 / span 2;
  max-height: 100%;
}

.interstitial-layer.is-corner .interstitial-image {
  grid-column: 1;
  grid-row: 1;
  aspect-ratio: 1;
  max-height: 104px;
}

.interstitial-copy {
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
}

.interstitial-layer.is-full-screen .interstitial-copy {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.interstitial-layer.is-full-screen:not(.has-image) .interstitial-copy {
  grid-column: 1;
}

.interstitial-layer.is-full-screen:not(.has-qr) .interstitial-copy {
  grid-row: 1 / span 2;
  align-self: center;
}

.interstitial-layer.is-corner .interstitial-copy {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.interstitial-title {
  overflow-wrap: anywhere;
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 28px;
  font-weight: 650;
  line-height: 1.22;
}

.interstitial-body {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin: 0;
  color: #d5ddda;
  font-size: 17px;
  line-height: 1.55;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
}

.interstitial-layer.is-corner .interstitial-title {
  margin-bottom: 7px;
  font-size: 18px;
}

.interstitial-layer.is-corner .interstitial-body {
  font-size: 14px;
  line-height: 1.42;
  -webkit-line-clamp: 5;
}

.interstitial-qr {
  display: none;
  width: min(180px, 100%);
  height: auto;
  aspect-ratio: 1;
  background: #ffffff;
}

.interstitial-layer.has-qr .interstitial-qr:not([hidden]) {
  display: block;
}

.interstitial-layer.is-full-screen .interstitial-qr {
  grid-column: 2;
  grid-row: 2;
  justify-self: start;
}

.interstitial-layer.is-full-screen:not(.has-image) .interstitial-qr {
  grid-column: 2;
}

.interstitial-layer.is-corner .interstitial-qr {
  grid-column: 1;
  grid-row: 2;
  width: 104px;
}

.playback-action {
  position: absolute;
  z-index: 7;
  bottom: var(--playback-action-bottom, 82px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  width: fit-content;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--panel-text);
  text-align: left;
}

.controls-hidden .playback-action { bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
.playback-still-frame { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 2; width: 100%; height: 100%; object-fit: contain; background: var(--page); pointer-events: none; }
.content-recovery-message, .content-recovery-detail { display: none !important; }

.playback-action p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.playback-action button, .boot-message button {
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.playback-action-primary, .boot-message button {
  width: auto;
  background: var(--panel-soft);
  color: var(--panel-text);
  font-weight: 500;
}
.boot-message button { min-height: 44px; }

.playback-action-secondary {
  margin-top: 0;
  background: transparent;
  color: inherit;
}

.playback-action button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

@media (pointer: coarse) { .playback-action button { min-height: 44px; } }
.platform-tv .playback-action button { min-height: 48px; font-size: 16px; }

.loading-overlay {
  position: absolute;
  bottom: 82px;
  left: 14px;
  z-index: 6;
  display: none !important;
  max-width: calc(100% - 28px);
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: rgb(24 29 34 / 82%);
  color: var(--panel-text);
  pointer-events: none;
  font-size: 12px;
  line-height: 18px;
  opacity: 1;
}

.loading-overlay strong { max-width: min(260px, 60vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
@keyframes loading-reveal { to { opacity: 1; } }
.controls-hidden .loading-overlay { bottom: max(12px, env(safe-area-inset-bottom, 0px)); }

.loading-line {
  width: 20px;
  height: 3px;
  overflow: hidden;
  background: #5d6870;
}

.loading-line::after {
  display: block;
  width: 45%;
  height: 100%;
  background: var(--accent);
  content: "";
  animation: loading-slide 1s ease-in-out infinite alternate;
}

@keyframes loading-slide {
  from { transform: translateX(0); }
  to { transform: translateX(120%); }
}

.video-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, max-content);
  min-height: calc(var(--controls-height) + env(safe-area-inset-bottom, 0px));
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgb(109 122 132 / 52%);
  background: var(--page);
  transition: opacity 160ms ease, transform 160ms ease;
}

.player-number {
  justify-self: end;
  flex-shrink: 0;
  min-width: 0;
  min-height: var(--sidebar-button-size);
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 8px;
  background: var(--panel);
  color: #fff;
  font: 13px/1.4 ui-monospace, monospace;
  overflow: hidden;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.platform-tv .player-number { font-size: 18px; }

.controls-hidden .video-controls {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

.controls-hidden .video-stage {
  cursor: none;
}

.control-actions {
  display: grid;
  grid-template-columns: 40px 40px 126px 42px 40px;
  align-items: center;
  gap: 4px;
}

.video-controls .video-icon-button {
  border: 0;
  background: transparent;
  color: var(--panel-text);
}

.video-controls input[type="range"] {
  width: 126px;
  accent-color: var(--accent);
}

.control-actions #volumeText {
  color: var(--panel-muted);
  font-size: 12px;
  text-align: right;
}

.stage-message {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 4;
  display: flex;
  text-align: center;
}
.stage-message:not(.passive-state):not(#emptyState) { padding: 28px; }
.stage-message:not(.passive-state):not(#emptyState) > .player-brand { margin-bottom: 13px; }

.stage-message h1 {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 600;
}

.stage-message p {
  margin: 0 0 8px;
  color: var(--panel-muted);
}

/* Passive failures keep the opaque safety surface; their only status is below. */
#emptyState > :not(.player-brand),
.stage-message.passive-state > :not(.player-brand) {
  display: none !important;
}

.activation-form {
  display: grid;
  width: min(320px, 100%);
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.activation-form input,
.activation-form button {
  min-width: 0;
  min-height: 40px;
}

.activation-form input {
  letter-spacing: 0;
  text-transform: none;
}

.activation-status {
  min-height: 20px;
  margin-top: 9px !important;
}

.install-button {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 36px;
  white-space: nowrap;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-color: #7c8992;
  background: transparent;
  color: inherit;
}

.install-guide {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgb(0 0 0 / 58%);
}

.install-guide-panel {
  width: min(420px, 100%);
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding: 18px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: 0 14px 36px rgb(0 0 0 / 38%);
}

.install-guide-header,
.install-guide-title,
.install-guide-actions {
  display: flex;
  align-items: center;
}

.install-guide-header {
  justify-content: space-between;
  gap: 12px;
}

.install-guide-title {
  min-width: 0;
  gap: 11px;
}

.install-guide-title img {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
}

.install-guide-title h2,
.install-guide-title p {
  margin: 0;
}

.install-guide-title h2 {
  font-size: 18px;
  font-weight: 650;
}

.install-guide-title p {
  margin-top: 3px;
  color: var(--panel-muted);
  font-size: 12px;
}

.install-guide-steps {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.install-guide-steps li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 38px;
  align-items: center;
  gap: 11px;
  color: var(--panel-text);
  line-height: 1.45;
}

.install-step-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #52606a;
  border-radius: 6px;
  background: var(--panel-soft);
  color: #89b8f8;
}

.install-step-icon .ui-icon {
  width: 19px;
  height: 19px;
}

.install-guide-actions {
  justify-content: flex-end;
}

.install-guide-actions button {
  min-width: 92px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.quiet-button {
  border-color: #7c8992;
  background: transparent;
  color: inherit;
}

.playback-status {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--panel-text);
}

#playbackStatus { flex: 1 1 7em; min-width: 7em; }
#licenseStatus { min-width: 0; flex: 0 1 auto; }

#playbackStatus,
#sourceStatus,
#licenseStatus {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sourceStatus,
#licenseStatus {
  color: var(--panel-muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(430px, calc(100% - 36px));
  padding: 11px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  background: var(--panel);
  color: white;
  box-shadow: 0 7px 20px rgb(0 0 0 / 22%);
}

@media (max-width: 1040px) {
  .control-actions {
    grid-template-columns: 40px 40px 40px;
    gap: 2px;
  }

  .control-actions input[type="range"],
  .control-actions #volumeText,
  #sourceStatus,
  #licenseStatus { display: none; }
}

@media (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    gap: 0;
    padding: 0;
  }

  .player-panel {
    grid-column: 1;
    grid-row: 1;
    border-radius: 0;
  }

  .video-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .channel-panel {
    grid-column: 1;
    grid-row: 2;
    border-top: 1px solid #39424a;
    border-right: 0;
    border-radius: 8px;
  }

  .app-shell.sidebar-collapsed .channel-panel {
    display: block;
    background: var(--page);
  }

  .expanded-sidebar {
    padding: 0 var(--sidebar-gutter);
  }

  .collapsed-sidebar {
    display: flex;
    height: 100%;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--page);
  }

  #sidebarExpandButton {
    display: inline-flex;
    width: auto;
    min-width: 112px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
  }

  .collapsed-label {
    display: inline;
    font-size: 14px;
    font-weight: 600;
  }

  .channel-row {
    grid-template-columns: 32px minmax(0, 1fr) 44px 16px;
    min-height: 48px;
  }

  .playback-status {
    min-height: 44px;
    gap: 4px;
  }

  .video-controls {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, max-content);
    min-height: calc(52px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
    padding: 4px 6px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  }

  .player-number {
    padding: 4px 6px;
    font-size: 12px;
  }

  #playbackStatus {
    font-size: 13px;
  }

  .loading-overlay {
    bottom: 64px;
    left: 8px;
    max-width: calc(100% - 16px);
  }

  .stage-message:not(.passive-state):not(#emptyState) {
    justify-content: flex-start;
    padding: 14px 12px 62px;
  }

  .stage-message:not(.passive-state):not(#emptyState) > .player-brand {
    display: none;
  }

  .stage-message h1 {
    margin-bottom: 6px;
    font-size: 18px;
  }

  .stage-message p {
    margin-bottom: 4px;
    font-size: 12px;
  }

  .activation-form input,
  .activation-form button {
    min-height: 38px;
  }

  .activation-status {
    min-height: 16px;
    margin-top: 5px !important;
  }

  .interstitial-layer.is-full-screen {
    padding: 12px;
  }

  .interstitial-layer.is-full-screen .interstitial-frame {
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-rows: 88px 88px;
    align-content: center;
    align-items: start;
    gap: 10px 12px;
  }

  .interstitial-layer.is-full-screen .interstitial-image {
    grid-column: 1;
    grid-row: 1;
    width: 88px;
    height: 88px;
  }

  .interstitial-layer.is-full-screen .interstitial-copy {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    max-height: 186px;
  }

  .interstitial-layer.is-full-screen:not(.has-image) .interstitial-copy {
    grid-column: 2;
  }

  .interstitial-layer.is-full-screen .interstitial-qr {
    grid-column: 1;
    grid-row: 2;
    width: 88px;
  }

  .interstitial-layer.is-full-screen:not(.has-image) .interstitial-qr {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .interstitial-layer.is-full-screen:not(.has-qr) .interstitial-image {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .interstitial-layer.is-full-screen:not(.has-image):not(.has-qr) .interstitial-copy {
    grid-column: 1 / span 2;
    grid-row: 1 / span 2;
  }

  .interstitial-layer.is-corner {
    padding: 8px;
    padding-bottom: 64px;
  }

  .interstitial-layer.is-corner .interstitial-frame {
    width: min(330px, 100%);
    max-width: min(330px, 100%);
    max-height: 100%;
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: 58px 58px;
    gap: 6px 8px;
    padding: 6px;
  }

  .interstitial-layer.is-corner .interstitial-image {
    width: 58px;
    height: 58px;
    max-height: 58px;
  }

  .interstitial-layer.is-corner .interstitial-copy {
    max-height: 122px;
  }

  .interstitial-layer.is-corner .interstitial-qr {
    width: 58px;
  }

  .interstitial-layer.is-corner:not(.has-image) .interstitial-qr {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .interstitial-layer.is-corner:not(.has-qr) .interstitial-image {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .interstitial-layer.is-corner:not(.has-image):not(.has-qr) .interstitial-copy {
    grid-column: 1 / span 2;
    grid-row: 1 / span 2;
  }

  .interstitial-layer .interstitial-title {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 6px;
    font-size: 20px;
    line-height: 1.2;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .interstitial-layer .interstitial-body {
    font-size: 14px;
    line-height: 1.35;
    -webkit-line-clamp: 5;
  }

  .interstitial-layer.is-corner .interstitial-title {
    font-size: 14px;
    -webkit-line-clamp: 2;
  }

  .interstitial-layer.is-corner .interstitial-body {
    font-size: 12px;
    line-height: 1.3;
    -webkit-line-clamp: 4;
  }

}

@media (max-width: 760px), (pointer: coarse) {
  .icon-button,
  .video-icon-button,
  .channel-tabs button,
  .favorite-button {
    min-height: 44px;
  }
}

.platform-tv,
.platform-tv.sidebar-collapsed {
  --tv-sidebar-width: 360px;
  --sidebar-gutter: 18px;
  --controls-height: 80px;
  grid-template-columns: minmax(0, 1fr);
}

.platform-tv .player-panel {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.platform-tv .video-stage {
  height: 100vh;
  height: 100dvh;
}

.platform-tv .channel-panel {
  position: fixed;
  top: 0; right: auto; bottom: 0; left: 0;
  z-index: 20;
  width: var(--tv-sidebar-width);
  max-width: 100vw;
  border-right: 1px solid #53606a;
  background: var(--page);
  box-shadow: 12px 0 30px rgb(0 0 0 / 38%);
}

.platform-tv.sidebar-collapsed .channel-panel {
  top: auto;
  width: 72px;
  height: var(--controls-height);
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.platform-tv .collapsed-sidebar {
  width: 72px;
  height: var(--controls-height);
  padding: 16px 12px;
  background: transparent;
  pointer-events: none;
}

.platform-tv .collapsed-sidebar .icon-button {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  border-color: #68757f;
  background: rgb(27 33 38 / 96%);
  pointer-events: auto;
}

.platform-tv .expanded-sidebar {
  padding: 0 var(--sidebar-gutter);
}

.platform-tv .list-footer {
  min-height: var(--sidebar-footer-height);
  flex-direction: row;
  align-items: center;
  padding-bottom: calc(var(--sidebar-footer-padding) + env(safe-area-inset-bottom, 0px));
}

.platform-tv .brand-identity strong {
  font-size: 22px;
}

.platform-tv .channel-row {
  grid-template-columns: 42px minmax(0, 1fr) 48px 18px;
  min-height: 48px;
  font-size: 16px;
}

.platform-tv .channel-name {
  font-size: 16px;
}

.platform-tv .icon-button,
.platform-tv .video-icon-button {
  width: 48px;
  min-width: 48px;
}

.platform-tv .icon-button,
.platform-tv .video-icon-button,
.platform-tv .channel-tabs button,
.platform-tv .favorite-button {
  min-height: 48px;
}

.platform-tv .video-controls {
  min-height: calc(var(--controls-height) + env(safe-area-inset-bottom, 0px));
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.platform-tv .control-actions {
  grid-template-columns: 48px 48px 150px 48px 48px;
  gap: 6px;
}

.platform-tv .video-controls input[type="range"] {
  width: 150px;
}

.platform-tv .loading-overlay {
  bottom: 94px;
  left: 20px;
}

.platform-tv .interstitial-layer.is-corner {
  padding-bottom: 96px;
}

@media (prefers-reduced-motion: reduce) {
  .video-controls {
    transition: none;
  }

  .loading-line::after {
    animation: none;
  }

  .status-working { animation: none; color: #f5f7f8; }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .channel-tabs {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  }
}

.direct-only-note {
  max-width: 34rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Compact controls keep the channel, source and touch targets readable.
   Portrait uses normal flow below the picture; fullscreen retains overlays. */
@media (max-width: 1100px), (pointer: coarse) {
  .app-shell:not(.platform-tv) { --sidebar-button-size: 44px; }
  /* No second channel count row when no filter needs explaining. */
  .app-shell:not(.platform-tv) .channel-filter-bar:has(#channelClearFiltersButton[hidden]) { display: none; }
  .app-shell:not(.platform-tv) .video-controls {
    --actions-min-width: 182px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 6px max(12px, env(safe-area-inset-right, 0px))
      max(6px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }
  .app-shell:not(.platform-tv) .playback-status {
    flex: 1 0 100%;
    flex-wrap: wrap;
    min-height: 28px;
    gap: 7px;
  }
  .app-shell:not(.platform-tv) #playbackStatus { font-size: 13px; line-height: 1.4; }
  .app-shell:not(.platform-tv) #sourceStatus {
    display: block; max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-size: 12px; color: #c4d0d9;
  }
  .app-shell:not(.platform-tv) #licenseStatus { display: none; }
  .app-shell:not(.platform-tv) .control-actions {
    flex: 1 1 var(--actions-min-width);
    min-width: min(100%, var(--actions-min-width));
    grid-template-columns: 44px 44px minmax(44px, 130px) 44px;
    gap: 2px;
  }
  .app-shell:not(.platform-tv) .control-actions #volumeSlider {
    display: block; min-width: 0; width: 100%; height: 44px; margin: 0;
  }
  .app-shell:not(.platform-tv) .control-actions #volumeText { display: none; }
  .app-shell:not(.platform-tv) .video-icon-button,
  .app-shell:not(.platform-tv) .icon-button {
    width: 44px; min-width: 44px; min-height: 44px; border-radius: 8px;
    touch-action: manipulation;
  }
  .app-shell:not(.platform-tv) .player-number {
    flex: 0 1 auto;
    min-width: 44px; min-height: 44px;
    max-width: min(124px, 100%);
    margin-left: auto;
    padding: 6px 8px; font-size: 12px;
    border-radius: 8px; border-color: #42515e;
  }
  .app-shell:not(.platform-tv) .loading-overlay { bottom: 106px; }
  .app-shell.controls-hidden:not(.platform-tv) .loading-overlay { bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
  .app-shell:not(.platform-tv) .video-stage { --playback-action-bottom: 110px; }
  .app-shell.device-volume:not(.platform-tv) .control-actions #volumeSlider { display: none; }
  .app-shell.device-volume:not(.platform-tv) .video-controls { --actions-min-width: 136px; }
  .app-shell.device-volume:not(.platform-tv) .control-actions { grid-template-columns: repeat(3, 44px); }
  .app-shell.device-volume:not(.platform-tv) .control-actions #volumeText { display: none; }
}

/* Compact normal playback reserves its controls outside the picture. */
@media (max-width: 1100px) {
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .player-brand-surface:not(#lockedState) { padding: 12px; }
}

/* Wider compact layouts have room for status, actions and Player ID together. */
@media (min-width: 761px) and (max-width: 1100px),
       (min-width: 761px) and (pointer: coarse) {
  .app-shell:not(.platform-tv) .video-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, max-content);
  }
  .app-shell:not(.platform-tv) .playback-status { flex-wrap: nowrap; }
  .app-shell:not(.platform-tv) #playbackStatus { min-width: 0; }
}

/* The wider Browse sidebar can leave too little room for a single control row. */
@media (min-width: 761px) and (max-width: 1100px) and (orientation: landscape) {
  html:not(.app-fullscreen-active) .app-shell.channel-browse-open:not(.sidebar-collapsed):not(.platform-tv)
    .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls { display: flex; }
}

@media (max-width: 760px) and (orientation: portrait),
       (max-width: 1100px) and (orientation: portrait) {
  .player-brand-surface { padding: 18px 18px calc(var(--playback-action-bottom, 12px) + 110px); }
  .player-brand { gap: 6px; }
  .player-brand img { width: 36px; }
  .player-brand strong { font-size: 16px; }
  .app-shell:not(.platform-tv) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh; min-height: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .app-shell:not(.platform-tv) .player-panel { grid-column: 1; grid-row: 1; }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) {
    display: flex; flex-direction: column;
    width: 100%; height: auto; max-height: none; aspect-ratio: auto;
  }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    position: relative; top: auto; right: auto; bottom: auto; left: auto; inset: auto;
    width: 100%; height: min(56.25vw, 44dvh); min-height: 120px; flex: 0 0 auto;
  }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls {
    position: relative; flex: 0 0 auto; opacity: 1; transform: none; pointer-events: auto;
    padding-bottom: 6px; background: var(--page);
  }
  /* Keep only a slim status row at rest; buffering never expands the controls.
     Touch/keyboard interaction restores the full-size 44px targets. */
  html:not(.app-fullscreen-active) .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls {
    min-height: 32px; padding-top: 2px; padding-bottom: 2px; row-gap: 0;
  }
  html:not(.app-fullscreen-active) .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .control-actions,
  html:not(.app-fullscreen-active) .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .player-number { display: none; }
  /* A quiet idle row has no information to reserve space for. Keep VOD and
     recovery actions reachable even when the pointer has been idle. */
  html:not(.app-fullscreen-active) .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen)
    .video-controls.quiet-status:not(:has(.vod-timeline:not([hidden]))):not(:has(#playbackAction:not([hidden]))) { display: none; }
  /* The always-visible portrait status row already reports buffering. */
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .loading-overlay { display: none; }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { --playback-action-bottom: 12px; }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .stage-message:not(.passive-state):not(#emptyState) {
    justify-content: center; padding: 12px;
  }
  .app-shell:not(.platform-tv) .activation-form input { font-size: 16px; }
  .app-shell:not(.platform-tv) .channel-panel {
    grid-column: 1; grid-row: 2; border-top: 1px solid #39424a; border-right: 0;
  }
  .app-shell:not(.platform-tv) .expanded-sidebar {
    --sidebar-gutter: 10px;
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .app-shell:not(.platform-tv) .channel-row {
    grid-template-columns: 32px minmax(0, 1fr) 44px 16px; min-height: 52px;
  }
  .app-shell:not(.platform-tv) .channel-name { font-size: 16px; }
  .app-shell:not(.platform-tv) .search-field input { min-height: 46px; font-size: 16px; }
  .app-shell.sidebar-collapsed:not(.platform-tv) { grid-template-rows: minmax(0, 1fr) auto; }
  html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { height: 100%; }
  html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    height: 0; min-height: 0; flex: 1 1 auto;
  }
  .app-shell.sidebar-collapsed:not(.platform-tv) .collapsed-sidebar {
    display: flex; align-items: center; justify-content: center; height: auto;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom, 0px));
  }
  .app-shell:not(.platform-tv) #sidebarExpandButton { width: auto; min-width: 132px; padding: 0 18px; gap: 10px; }
  .app-shell:not(.platform-tv) .collapsed-label { display: inline; }
}

@media (max-width: 1100px) and (orientation: landscape) {
  .app-shell:not(.platform-tv) {
    grid-template-columns: calc(clamp(236px, 28vw, 285px) + env(safe-area-inset-left, 0px)) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr); height: 100dvh; min-height: 0;
  }
  .app-shell.sidebar-collapsed:not(.platform-tv) {
    grid-template-columns: calc(56px + env(safe-area-inset-left, 0px)) minmax(0, 1fr);
  }
  .app-shell:not(.platform-tv) .player-panel { grid-column: 2; grid-row: 1; }
  .app-shell:not(.platform-tv) .channel-panel { grid-column: 1; grid-row: 1; border-top: 0; border-right: 1px solid #39424a; }
  /* Normal landscape playback reserves its toolbar below the picture.
     Fullscreen keeps the existing auto-hiding overlay controls. */
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) {
    display: flex; flex-direction: column; height: 100%; max-height: none; aspect-ratio: auto;
  }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    position: relative; top: auto; right: auto; bottom: auto; left: auto; inset: auto; height: 0; min-height: 0; flex: 1 1 auto;
  }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls {
    position: relative; flex: 0 0 auto; opacity: 1; transform: none; pointer-events: auto;
  }
  html:not(.app-fullscreen-active) .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen)
    .video-controls:not(:has(.vod-timeline:not([hidden]))):not(:has(#playbackAction:not([hidden]))) { display: none; }
  .app-shell:not(.platform-tv) .expanded-sidebar {
    padding-left: calc(var(--sidebar-gutter) + env(safe-area-inset-left, 0px));
  }
  @supports (padding: env(safe-area-inset-left)) {
    .app-shell:not(.platform-tv) .sidebar-more-panel {
      left: calc(var(--sidebar-gutter) + env(safe-area-inset-left, 0px));
    }
  }
  .app-shell:not(.platform-tv) .collapsed-sidebar {
    display: grid; justify-items: center;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px))
      calc(6px + env(safe-area-inset-left, 0px));
  }
  /* The sidebar already reserves the viewport's left cutout in normal layout. */
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls {
    padding-left: 12px;
    column-gap: 4px;
  }
  .app-shell:not(.platform-tv) #sidebarExpandButton { width: 44px; min-width: 44px; padding: 0; }
  .app-shell:not(.platform-tv) .collapsed-label { display: none; }
  .app-shell:not(.platform-tv) .player-number { max-width: min(112px, 100%); padding-left: 4px; padding-right: 4px; }
}

@media (max-width: 360px) {
  .app-shell:not(.platform-tv) .video-controls { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .app-shell:not(.platform-tv) .control-actions { grid-template-columns: 44px 44px minmax(28px, 1fr) 44px; }
  .app-shell:not(.platform-tv) .player-number { max-width: min(108px, 100%); padding: 4px; }
}

/* Short portrait screens reserve a usable row below the visible entries,
   Search and footer. Message opening cannot change the picture's height. */
@media (max-width: 1100px) and (max-height: 600px) and (orientation: portrait) {
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv):not(.sidebar-collapsed) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    height: min(56.25vw, 30dvh);
  }
}

/* Reserve room for both the vertical brand and usable bottom actions. */
@media (max-width: 1100px) and (max-height: 600px) and (orientation: portrait) {
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { --playback-action-bottom: 4px; }
  html:not(.app-fullscreen-active) .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface { min-height: 120px; }
  .player-brand-surface { padding: 4px 18px 114px; }
  .player-brand { gap: 4px; }
  .player-brand img { width: 24px; }
  .player-brand strong { font-size: 14px; }
}

/* Manual feedback remains separate from playback/recovery announcements. */
.channel-row.channel-has-report { grid-template-columns: minmax(0, 1fr) 78px 28px 13px; padding: 0 4px; }
.channel-has-report .channel-index { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.channel-has-report .channel-name { grid-column: 1; grid-row: 1; padding-left: 0; }
.channel-has-report .manual-source-report { grid-column: 2; grid-row: 1; }
.channel-has-report .favorite-button { grid-column: 3; grid-row: 1; }
.channel-has-report .availability-dot { grid-column: 4; grid-row: 1; }
.channel-browse-open .channel-row.channel-has-report { grid-template-columns: minmax(0, 1fr) 78px 32px 13px; min-height: 53px; }
.manual-source-report { min-width: 0; }
.manual-source-report button { width: 100%; min-height: 36px; height: 36px; padding: 2px 6px; border: 1px solid #687984; border-radius: 6px; background: #202e38; color: #fff; font: inherit; font-size: 14px; line-height: 14px; white-space: normal; cursor: pointer; }
.manual-source-report button:focus-visible { outline: 3px solid #8dccff; outline-offset: 3px; }
.manual-source-report button:disabled { opacity: .65; cursor: default; }
.platform-tv .channel-row.channel-has-report { grid-template-columns: minmax(0, 1fr) 84px 48px 13px; min-height: 57px; }
.platform-tv .manual-source-report button { font-size: 16px; line-height: 18px; min-height: 48px; height: 48px; }
@media (max-width: 1100px), (pointer: coarse) {
  .app-shell:not(.platform-tv) { --channel-row-height: 53px; }
  .app-shell:not(.platform-tv) .channel-row { min-height: 53px; }
  .app-shell:not(.platform-tv) .channel-row.channel-has-report { grid-template-columns: minmax(0, 1fr) 78px 44px 13px; }
  .app-shell:not(.platform-tv) .channel-has-report .favorite-button { width: 44px; min-width: 44px; }
  .app-shell:not(.platform-tv) .manual-source-report button { min-height: 44px; height: 44px; }
}

/* A filtered catalog uses only the height its rows and controls need.
   Long results retain the same scrolling limit; More opens in the full panel. */
.sidebar-search-open { --sidebar-search-height: 60px; }
.platform-tv {
  --channel-row-height: 57px;
  --sidebar-button-size: 48px;
  --sidebar-footer-minimum: calc(48px + 2 * var(--sidebar-footer-padding) + var(--sidebar-footer-border));
}
.app-shell.catalog-filtered:not(.compact-player-ui):not(.channel-browse-open):not(.sidebar-collapsed):not(.sidebar-menu-open) .channel-panel {
  align-self: end;
  height: calc(var(--filtered-row-count) * var(--channel-row-height) + var(--sidebar-search-height) + var(--sidebar-footer-height) + var(--channel-header-height, 76px) + 1px);
  max-height: 100%;
}
.platform-tv.catalog-filtered:not(.compact-player-ui):not(.channel-browse-open):not(.sidebar-collapsed):not(.sidebar-menu-open) .channel-panel {
  top: auto;
  bottom: 0;
  max-height: 100vh;
}
@supports (height: 100dvh) {
  .platform-tv.catalog-filtered:not(.compact-player-ui):not(.channel-browse-open):not(.sidebar-collapsed):not(.sidebar-menu-open) .channel-panel {
    max-height: 100dvh;
  }
}
.app-shell.platform-tv { grid-template-columns: minmax(0, 1fr); }
html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .video-controls {
  left: var(--tv-sidebar-width);
}
html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .playback-action {
  left: calc(var(--tv-sidebar-width) + 12px);
}
@media (max-width: 1166px) {
  html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .video-controls {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    grid-gap: 4px;
  }
  html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .control-actions { justify-self: end; }
  html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .playback-status { grid-column: 1 / -1; }
}
@media (max-width: 1040px) {
  .platform-tv .control-actions { grid-template-columns: repeat(3, 48px); }
}
@supports (padding: env(safe-area-inset-bottom)) {
  .app-shell { --sidebar-footer-height: calc(var(--sidebar-footer-minimum) + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 760px) {
  .app-shell:not(.platform-tv) { --channel-row-height: 53px; }
}
@media (max-width: 1100px) and (orientation: portrait) {
  .app-shell:not(.platform-tv) { --channel-row-height: 53px; --sidebar-footer-minimum: 60px; }
  .app-shell:not(.platform-tv).sidebar-search-open { --sidebar-search-height: 64px; }
  .app-shell:not(.platform-tv) .search-field { height: 48px; }
  .app-shell:not(.platform-tv) .list-footer { min-height: var(--sidebar-footer-height); }
}

/* Collapsing releases the picture's full width. Only the expand target
   overlays the lower-left control area; no full-height rail remains. */
.app-shell.sidebar-collapsed:not(.platform-tv),
.app-shell.platform-tv.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.app-shell.sidebar-collapsed .player-panel { grid-column: 1; grid-row: 1; }
.app-shell.sidebar-collapsed .channel-panel {
  position: fixed;
  top: auto; right: auto; bottom: 0; left: 0;
  width: calc(var(--sidebar-button-size) + 16px);
  height: calc(var(--sidebar-button-size) + 16px);
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}
.app-shell.sidebar-collapsed .channel-panel .collapsed-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  padding: 8px;
  background: transparent;
}
.app-shell.sidebar-collapsed #sidebarExpandButton {
  width: var(--sidebar-button-size);
  height: var(--sidebar-button-size);
  min-width: var(--sidebar-button-size);
  min-height: var(--sidebar-button-size);
  padding: 0;
  border-radius: 8px;
  background: rgba(24, 32, 40, 0.72);
  pointer-events: auto;
}
.app-shell.sidebar-collapsed .collapsed-label { display: none; }
html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .player-panel .video-stage:not(.app-fullscreen) .video-controls {
  padding-left: calc(var(--sidebar-button-size) + 24px);
  min-height: calc(var(--sidebar-button-size) + 16px);
}
html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .video-stage:not(.app-fullscreen) .loading-overlay,
html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .video-stage:not(.app-fullscreen) .playback-action {
  left: calc(var(--sidebar-button-size) + 24px);
}
@supports (padding: env(safe-area-inset-left)) {
  .app-shell.sidebar-collapsed .channel-panel {
    width: calc(var(--sidebar-button-size) + 16px + env(safe-area-inset-left, 0px));
    height: calc(var(--sidebar-button-size) + 16px + env(safe-area-inset-bottom, 0px));
  }
  .app-shell.sidebar-collapsed .channel-panel .collapsed-sidebar {
    padding-left: calc(8px + env(safe-area-inset-left, 0px));
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .player-panel .video-stage:not(.app-fullscreen) .video-controls {
    padding-left: calc(var(--sidebar-button-size) + 24px + env(safe-area-inset-left, 0px));
    min-height: calc(var(--sidebar-button-size) + 16px + env(safe-area-inset-bottom, 0px));
  }
  html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .video-stage:not(.app-fullscreen) .loading-overlay,
  html:not(.app-fullscreen-active) .app-shell.sidebar-collapsed .video-stage:not(.app-fullscreen) .playback-action {
    left: calc(var(--sidebar-button-size) + 24px + env(safe-area-inset-left, 0px));
  }
}
/* VOD controls share the existing playback toolbar and wrap at narrow widths. */
.vod-timeline { flex: 1 1 180px; min-width: 80px; min-height: 44px; max-width: 100%; }
.vod-resume { white-space: normal; }

/* Fullscreen includes the existing channel panel; it never re-parents the video. */
#fullscreenChannelsButton { display: none; }
html.app-fullscreen-active .app-shell {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 100; width: 100%; height: 100%;
  min-height: 0; max-height: none; display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr); overflow: hidden;
}
html.app-fullscreen-active .app-shell.channel-browse-open {
  grid-template-columns: minmax(0, 1fr);
}
html.app-fullscreen-active .app-shell .player-panel {
  grid-column: 1; grid-row: 1; width: 100%; height: 100%; min-height: 0;
}
html.app-fullscreen-active .app-shell .video-stage {
  width: 100%; height: 100%; min-height: 0; max-height: none; aspect-ratio: auto;
}
html.app-fullscreen-active .app-shell .video-surface { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; min-height: 0; }
html.app-fullscreen-active .app-shell .channel-panel { display: none; }
html.app-fullscreen-active .app-shell.fullscreen-channel-picker-open .channel-panel {
  display: block; position: absolute; top: 0; right: auto; bottom: 0; left: 0; inset: 0 auto 0 0; z-index: 120;
  grid-row: 1; grid-column: 1;
  width: 360px; max-width: 92vw; width: min(360px, 92vw); height: 100%; max-height: 100%; border-radius: 0;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 8px 0 28px rgb(0 0 0 / 45%); background: #101720;
}
html.app-fullscreen-active #fullscreenChannelsButton { display: inline-flex; }
html.app-fullscreen-active .app-shell .video-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
}

/* TV focus must remain visible on WebViews predating :focus-visible. */
.platform-tv :focus,
.platform-tv ~ dialog :focus { outline: 3px solid var(--focus); outline-offset: -3px; }
html.app-fullscreen-active .platform-tv.fullscreen-channel-picker-open .channel-panel {
  width: var(--tv-sidebar-width);
}

/* Older TV WebViews commonly expose a 960x540 CSS viewport. Keep the
   controls remote-sized while giving the picture and channel names room. */
@media (max-height: 600px) {
  .platform-tv {
    --tv-sidebar-width: 320px;
    --sidebar-gutter: 10px;
    --controls-height: 64px;
    --channel-row-height: 45px;
    --sidebar-button-size: 44px;
    --sidebar-footer-minimum: calc(44px + 2 * var(--sidebar-footer-padding) + var(--sidebar-footer-border));
  }
  .platform-tv .channel-row,
  .platform-tv.channel-browse-open .channel-row { min-height: 45px; padding: 0 6px; font-size: 16px; grid-template-columns: 30px minmax(0, 1fr) 44px 13px; }
  .platform-tv .channel-name,
  .platform-tv .sidebar-action-label { font-size: 16px; line-height: 20px; }
  .app-shell.platform-tv .sidebar-actions .icon-button,
  .platform-tv .icon-button,
  .platform-tv .video-icon-button,
  .platform-tv .favorite-button,
  .platform-tv.channel-browse-open .favorite-button { min-width: 44px; min-height: 44px; }
  .platform-tv .icon-button,
  .platform-tv .video-icon-button,
  .platform-tv .favorite-button,
  .platform-tv.channel-browse-open .favorite-button { width: 44px; }
  .platform-tv .channel-row.channel-has-report { min-height: 44px; grid-template-columns: minmax(0, 1fr) 76px 44px 13px; }
  .platform-tv .manual-source-report button { min-height: 44px; height: 44px; font-size: 12px; line-height: 16px; }
  .platform-tv .sidebar-more-panel button,
  .platform-tv .player-language-control select { min-height: 44px; font-size: 14px; }
  .platform-tv .brand-identity strong { font-size: 16px; }
  .platform-tv .video-controls { padding: 8px 12px; }
}

/* TV remote navigation: one narrow overlay and four daily actions. Keep
   search above the scrolling list so an on-screen keyboard cannot cover it. */
.tv-only { display: none !important; }
.platform-tv .tv-only { display: block !important; }
.app-shell.platform-tv { --tv-sidebar-width: 300px; }
.app-shell.platform-tv.channel-browse-open { grid-template-columns: minmax(0, 1fr); }
.app-shell.platform-tv .channel-panel,
.app-shell.platform-tv.channel-browse-open .channel-panel {
  position: fixed; top: 0; right: auto; bottom: 0; left: 0;
  width: var(--tv-sidebar-width); max-width: 35vw; height: 100%;
  border: 0; background: #101720;
}
.platform-tv .expanded-sidebar { height: 100%; min-height: 0; }
.app-shell.platform-tv.channel-browse-open .player-panel { grid-column: 1; }
.app-shell.platform-tv.sidebar-collapsed .channel-panel { display: none; }
.app-shell.platform-tv.catalog-filtered:not(.channel-browse-open):not(.sidebar-collapsed):not(.sidebar-menu-open) .channel-panel {
  height: 100%; max-height: 100%;
}
.platform-tv .non-tv-only,
.platform-tv .channel-browse-entry,
.platform-tv .channel-filter-bar,
.platform-tv #sidebarCollapseButton,
.platform-tv #channelPagination,
.platform-tv #sharePlayerButton,
.platform-tv #installButton,
.platform-tv .video-controls #volumeSlider,
.platform-tv .video-controls #volumeText,
.platform-tv #fullscreenButton,
.platform-tv #fullscreenChannelsButton,
.platform-tv #playerNumber { display: none !important; }
.platform-tv .list-footer {
  order: -5; min-height: 56px; border-top: 0;
  border-bottom: 1px solid rgba(177, 195, 210, .16);
  padding-top: 6px; padding-bottom: 6px; background: transparent;
}
.platform-tv .sidebar-actions { width: 100%; gap: 3px; }
.platform-tv #allChannelsTab { order: 0; }
.platform-tv #favoriteTab { order: 1; }
.platform-tv #channelSearchButton { order: 2; }
.platform-tv #sidebarMoreButton { order: 3; }
.app-shell.platform-tv .sidebar-actions .icon-button {
  flex: 1 1 0; min-width: 0; width: auto; min-height: 44px;
  border-color: transparent; background: transparent; padding: 3px;
}
.platform-tv .sidebar-actions .sidebar-action-label { font-size: 16px; line-height: 20px; }
.app-shell.platform-tv .sidebar-actions .icon-button[aria-pressed="true"],
.app-shell.platform-tv .sidebar-actions .icon-button[aria-expanded="true"] {
  background: rgba(50, 111, 157, .6); border-color: #6a9bbd;
}
.platform-tv .search-field {
  order: -4; margin: 8px 0; flex: 0 0 auto; display: flex;
  min-width: 0; height: 52px; padding: 3px 4px; gap: 4px;
}
.platform-tv .search-field .ui-icon { display: none; }
.platform-tv .search-field input { flex: 1 1 0; min-width: 0; width: auto; font-size: 16px; height: 44px; min-height: 44px; }
.platform-tv #channelSearchClearButton { flex: 0 0 48px; width: 48px; min-width: 48px; height: 44px; min-height: 44px; padding: 4px; }
.platform-tv #channelSearch::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.app-shell:not(.platform-tv) #channelSearchClearButton { display: none; }
.platform-tv .channel-browse-controls { order: -3; }
.app-shell.platform-tv .channel-list,
.app-shell.platform-tv.channel-browse-open .channel-list {
  order: 0; display: block; background: transparent; border: 0; border-radius: 0;
  color: #ecf2f8; min-height: 44px; flex: 1 1 0;
}
.app-shell.platform-tv .channel-row,
.app-shell.platform-tv.channel-browse-open .channel-row {
  grid-template-columns: 26px minmax(0, 1fr) 44px;
  min-height: 45px; padding: 0 3px; background: transparent;
  border-bottom: 1px solid rgba(177, 195, 210, .1); border-right: 0;
  color: #ecf2f8; font-size: 16px;
}
.platform-tv .channel-name { font-size: 16px; }
.app-shell.platform-tv .channel-row[aria-selected="true"] { background: rgba(41, 108, 146, .5); }
.platform-tv .channel-row .availability-dot { display: none; }
.platform-tv .favorite-button,
.platform-tv.channel-browse-open .favorite-button {
  width: 44px; min-width: 44px; min-height: 44px; color: #bbcad7;
}
.platform-tv .favorite-button.active { color: #ffd56b; }
.app-shell.platform-tv .channel-row.channel-has-report {
  grid-template-columns: minmax(0, 1fr) 76px 44px; min-height: 45px;
}
.app-shell.platform-tv .manual-source-report button {
  min-height: 44px; height: 44px; padding: 2px 3px; font-size: 14px; line-height: 16px;
}
.platform-tv .sidebar-more-panel {
  top: 62px; bottom: auto; max-height: calc(100% - 118px);
  grid-template-columns: 1fr; font-size: 14px;
}
.platform-tv .sidebar-more-panel .brand-bar { grid-row: 1; }
.platform-tv #tvAudioSettings {
  display: grid !important; grid-template-columns: 44px minmax(0, 1fr) 32px;
  align-items: center; gap: 6px; min-width: 0;
}
.platform-tv #tvAudioSettings label { grid-column: 1 / -1; }
.platform-tv #tvAudioSettings input[type="range"] { width: 100%; min-width: 0; }
.platform-tv .tv-remote-help {
  order: 5; flex: 0 0 auto; min-height: 36px; margin: 6px 0;
  color: #b8c7d5; font-size: 14px; line-height: 20px; white-space: pre-line;
}
.platform-tv .control-actions { display: flex; flex-wrap: wrap; }
html.app-fullscreen-active .app-shell.platform-tv.fullscreen-channel-picker-open .channel-panel {
  width: var(--tv-sidebar-width); max-width: 35vw;
}
@media (max-height: 600px) {
  .app-shell.platform-tv { --tv-sidebar-width: 280px; }
}

/* TV and touch players reuse one floating channel panel. Desktop tools and
   their layout stay available; search reveals the optional quick filters. */
.compact-player-ui {
  --compact-control-height: 44px;
  --compact-row-height: 45px;
  --compact-card-padding: 18px;
}
.app-shell.compact-player-ui.platform-tv,
#playerView.platform-tv ~ .activation-code-dialog.compact-player-ui {
  --compact-control-height: 40px;
  --compact-row-height: 38px;
  --compact-card-padding: 16px;
}
.app-shell.compact-player-ui {
  --floating-panel-width: 320px;
  --channel-row-height: var(--compact-row-height);
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
}
.app-shell.compact-player-ui.platform-tv { --floating-panel-width: var(--tv-sidebar-width); }
.app-shell.compact-player-ui .player-panel { grid-column: 1; grid-row: 1; width: 100%; height: 100%; }
.app-shell.compact-player-ui:not(.sidebar-collapsed) .channel-panel {
  position: fixed; top: 0; right: auto; bottom: 0; left: 0; z-index: 30;
  width: var(--floating-panel-width); max-width: calc(100vw - 24px); height: 100%; max-height: 100%;
  border: 0; border-radius: 0; background: #101720;
  box-shadow: 8px 0 28px rgba(0, 0, 0, .35);
}
.app-shell.compact-player-ui .expanded-sidebar { height: 100%; min-height: 0; }
.app-shell.compact-player-ui #sidebarMoreButton,
.app-shell.compact-player-ui #playerNumber,
.app-shell.compact-player-ui #volumeSlider,
.app-shell.compact-player-ui #volumeText { display: none !important; }
.app-shell.compact-player-ui .channel-filter-bar { display: none; }
.app-shell.compact-player-ui.catalog-filtered:not(.sidebar-search-open) .channel-filter-bar {
  display: flex !important; order: -4;
}
.app-shell.compact-player-ui #channelClearFiltersButton { min-width: var(--compact-control-height); min-height: var(--compact-control-height); }
.app-shell.compact-player-ui:not(.channel-browse-open) .channel-browse-entry { display: none; }
.app-shell.compact-player-ui .list-footer {
  order: -5; min-height: calc(var(--compact-control-height) + 10px); border-top: 0; border-bottom: 1px solid rgba(177, 195, 210, .16);
  padding-top: 4px; padding-bottom: 4px; background: transparent;
}
.app-shell.compact-player-ui .sidebar-more-panel { top: calc(var(--compact-control-height) + 16px); bottom: auto; max-height: calc(100% - 118px); gap: 6px; padding: 10px; }
.app-shell.compact-player-ui .sidebar-more-panel button,
.app-shell.compact-player-ui .player-language-control select {
  min-height: var(--compact-control-height); padding: 4px 6px; font-size: 16px; line-height: 20px;
}
.app-shell.compact-player-ui .icon-button,
.app-shell.compact-player-ui .sidebar-actions .icon-button,
.app-shell.compact-player-ui .video-icon-button,
.app-shell.compact-player-ui .video-source-button,
.app-shell.compact-player-ui #resumePlaybackButton {
  min-height: var(--compact-control-height); height: var(--compact-control-height);
}
.app-shell.compact-player-ui .search-field {
  order: -4; flex: 0 0 auto; height: calc(var(--compact-control-height) + 2px); margin: 4px 0; padding: 0 4px;
}
.app-shell.compact-player-ui .search-field input,
.app-shell.compact-player-ui #channelSearchClearButton {
  min-height: var(--compact-control-height); height: var(--compact-control-height);
}
.app-shell.compact-player-ui .channel-browse-controls { order: -2; }
.app-shell.compact-player-ui .channel-list { order: 0; display: block; background: transparent; color: #ecf2f8; }
.app-shell.compact-player-ui .channel-row,
.app-shell.compact-player-ui.channel-browse-open .channel-row,
.app-shell.compact-player-ui .channel-row.channel-has-report {
  min-height: var(--compact-row-height); padding-top: 0; padding-bottom: 0; color: #ecf2f8;
}
.app-shell.compact-player-ui .channel-name { font-size: 16px; }
.app-shell.compact-player-ui .channel-row[aria-selected="true"] { background: rgba(41, 108, 146, .5); }
.app-shell.compact-player-ui .channel-row .favorite-button,
.app-shell.compact-player-ui .manual-source-report button { min-height: 44px; height: 44px; padding-top: 0; padding-bottom: 0; }
.app-shell.compact-player-ui.platform-tv .channel-row .favorite-button,
.app-shell.compact-player-ui.platform-tv .manual-source-report button { min-height: 36px; height: 36px; }
.app-shell.compact-player-ui .favorite-button { color: #bbcad7; }
.app-shell.compact-player-ui .favorite-button.active { color: #ffd56b; }
.channel-quick-filters { display: flex; order: -3; flex: 0 0 auto; flex-wrap: wrap; gap: 4px; padding: 0 0 6px; }
.channel-quick-filters button { flex: 1 1 0; min-width: 44px; min-height: var(--compact-control-height, 44px); padding: 4px; font-size: 16px; }
.channel-quick-filters button[aria-pressed="true"] { border-color: #6a9bbd; background: #244d69; color: white; }
.app-shell.compact-player-ui:not(.platform-tv) .sidebar-actions { width: 100%; }
.app-shell.compact-player-ui .sidebar-actions .icon-button { border-color: transparent; background: transparent; }
.app-shell.compact-player-ui .sidebar-actions .icon-button[aria-pressed="true"],
.app-shell.compact-player-ui .sidebar-actions .icon-button[aria-expanded="true"]:not(#sidebarCollapseButton) { background: rgba(50, 111, 157, .35); }
.app-shell.compact-player-ui:not(.platform-tv) .sidebar-actions .icon-button { flex: 1 1 0; min-width: 0; width: auto; }
.app-shell.compact-player-ui:not(.platform-tv) #sidebarCollapseButton { order: 0; }
.app-shell.compact-player-ui:not(.platform-tv) #favoriteTab { order: 1; }
.app-shell.compact-player-ui:not(.platform-tv) #channelSearchButton { order: 2; }
.app-shell.compact-player-ui:not(.platform-tv) #sidebarMoreButton { order: 3; }
.app-shell.compact-player-ui.sidebar-collapsed .channel-panel {
  top: 0; bottom: auto; width: auto; height: calc(var(--compact-control-height) + 16px);
  max-width: calc(100vw - 16px); border: 0; background: transparent; box-shadow: none;
}
.app-shell.compact-player-ui.sidebar-collapsed .channel-panel .collapsed-sidebar { width: auto; }
.app-shell.compact-player-ui.sidebar-collapsed #sidebarExpandButton {
  display: inline-flex; width: auto; min-width: var(--compact-control-height);
  min-height: var(--compact-control-height); height: var(--compact-control-height); gap: 6px; padding: 0 12px;
}
.app-shell.compact-player-ui.sidebar-collapsed .collapsed-label { display: inline; }
.app-shell.compact-player-ui.platform-tv.sidebar-collapsed .channel-panel,
html.app-fullscreen-active .app-shell.compact-player-ui.sidebar-collapsed .channel-panel { display: block; }
.app-shell.compact-player-ui.sidebar-collapsed.controls-hidden .channel-panel:not(:focus-within) { visibility: hidden; }
.app-shell.compact-player-ui #fullscreenChannelsButton { display: none !important; }
html:not(.app-fullscreen-active) .app-shell.compact-player-ui.sidebar-collapsed .player-panel .video-stage:not(.app-fullscreen) .video-controls {
  padding-left: 12px;
}
.app-shell.compact-player-ui .tv-remote-help { min-height: 32px; margin-top: 4px; margin-bottom: 4px; line-height: 18px; }
.platform-tv .tv-remote-help { display: none !important; }
.app-shell.compact-player-ui.platform-tv .list-footer { min-height: 40px; padding-top: 0; padding-bottom: 0; border-bottom: 0; }
.app-shell.compact-player-ui.platform-tv .channel-quick-filters [data-channel-query=""] { display: none; }
html:not(.app-fullscreen-active) #playerView.app-shell.compact-player-ui.platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .video-controls,
html.app-fullscreen-active #playerView.app-shell.compact-player-ui.platform-tv.fullscreen-channel-picker-open .video-controls {
  left: var(--tv-sidebar-width); right: 0; min-height: 52px; padding: 6px 12px;
  grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
}
html:not(.app-fullscreen-active) .app-shell.compact-player-ui.platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .playback-status,
html.app-fullscreen-active .app-shell.compact-player-ui.platform-tv.fullscreen-channel-picker-open .playback-status {
  grid-column: auto; min-width: 0; flex-wrap: nowrap;
}
.app-shell.compact-player-ui.platform-tv #playbackStatus { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html:not(.app-fullscreen-active) #playerView.compact-player-ui .video-stage:not(.app-fullscreen):not(:fullscreen) {
  display: block; position: relative; width: 100%; height: 100%; min-height: 0; max-height: none; aspect-ratio: auto;
}
html:not(.app-fullscreen-active) #playerView.compact-player-ui .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; min-height: 0;
}
html:not(.app-fullscreen-active) #playerView.compact-player-ui .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls {
  position: absolute; left: 0; right: 0; bottom: 0; opacity: 1; transform: none;
}
html:not(.app-fullscreen-active) #playerView.compact-player-ui.controls-hidden .video-stage:not(.app-fullscreen):not(:fullscreen) .video-controls { display: none; }
