: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(max(44px, var(--sidebar-button-size)) + 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;
}

.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: var(--page);
  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: rgba(238, 246, 253, 0.9);
  color: #1d5688;
  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: 14px;
  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: 100%; 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: 0 0 auto; min-height: 40px; padding: 6px 9px; }
#channelPageStatus { min-width: 0; text-align: center; line-height: 1.4; font-size: 12px; }
.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(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: 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);
}

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

.availability-dot {
  justify-self: center;
}

.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: var(--page);
  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; }
.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 { min-height: 44px; } }
.platform-tv .sidebar-more-panel button { min-height: 48px; font-size: 16px; }
.playback-diagnostics-status { margin: 0; color: var(--panel-muted); font-size: 12px; overflow-wrap: anywhere; }
.playback-diagnostics-status:empty { display: none; }
.playback-diagnostics-text { width: 100%; min-width: 0; max-height: 180px; 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; inset: 0; overflow: hidden; }

.content-recovery { display: none; }
.authorization-checking .content-recovery,
.content-protected .content-recovery,
.playback-waiting .content-recovery {
  display: flex; position: absolute; 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;
  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;
  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; 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;
  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;
  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;
  }

  .video-controls 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 {
  --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: 420px;
  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; }
  .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; }
}

/* 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) {
  .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; }
  .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;
  }
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    position: relative; inset: auto;
    width: 100%; height: min(56.25vw, 44dvh); min-height: 208px; flex: 0 0 auto;
  }
  .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. */
  .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;
  }
  .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .control-actions,
  .app-shell.controls-hidden:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .player-number { display: none; }
  /* The always-visible portrait status row already reports buffering. */
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .loading-overlay { display: none; }
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { --playback-action-bottom: 12px; }
  .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: 15px; }
  .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; }
  .app-shell.sidebar-collapsed:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { height: 100%; }
  .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; }
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { height: 100%; max-height: none; aspect-ratio: auto; }
  .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. */
  .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) {
  .app-shell:not(.platform-tv):not(.sidebar-collapsed) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface {
    height: min(56.25vw, 22dvh);
  }
}

/* Reserve room for both the vertical brand and usable bottom actions. */
@media (max-width: 1100px) and (max-height: 600px) and (orientation: portrait) {
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) { --playback-action-bottom: 4px; }
  .app-shell:not(.platform-tv) .video-stage:not(.app-fullscreen):not(:fullscreen) .video-surface { min-height: 180px; }
  .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; }
.app-shell.catalog-filtered: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(.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(.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: 420px;
}
html:not(.app-fullscreen-active) .platform-tv:not(.sidebar-collapsed) .video-stage:not(.app-fullscreen) .playback-action {
  left: 432px;
}
@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));
  }
}
