#view-player {
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

#view-player * {
  pointer-events: auto;
}

/* Subtitle cues — Blink draws these on both the preview and native on-device (it honors
   ::cue). A soft text-shadow keeps them legible over any background without the
   solid black box a default cue box paints; ui-monospace gives the system mono (the
   TV ignores it and uses "Droid Sans Mono"), with per-script fallback for CJK etc. */
#video-player::cue {
  background-color: transparent;
  color: #fff;
  font-size: 4.2vh;
  text-shadow: 0 0 6px rgb(0 0 0 / 90%), 0 0 3px rgb(0 0 0 / 90%), 1px 1px 2px rgb(0 0 0 / 90%);
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
  font-family: ui-monospace, "SFMono-Regular", "Droid Sans Mono", monospace;
}

/* User-selectable cue size/style (Settings → Subtitles, or the player's Subtitles
   menu). Applied via classes on #video-player rather than a CSS variable — ::cue
   custom-property support isn't guaranteed on Chromium 53. The base rule above
   supplies the "medium"/"default" values, so only the other sizes/styles need a rule. */
#video-player.subtitle-size-small::cue { font-size: 2.8vh; }
#video-player.subtitle-size-large::cue { font-size: 5.4vh; }
#video-player.subtitle-size-xlarge::cue { font-size: 6.6vh; }
#video-player.subtitle-size-xxlarge::cue { font-size: 7.8vh; }

/* Black = the classic boxed look; text-shadow stays for legibility on partial-coverage cues. */
#video-player.subtitle-style-black::cue { background-color: rgb(0 0 0 / 80%); }
#video-player.subtitle-style-yellow::cue { color: #ffd400; }

/* WebVTT <c.class> speaker colors — the teletext palette (white default +
   red/green/yellow/blue/magenta/cyan). Render on both paths — the desktop preview
   and native on-device (Blink draws the cues and honors ::cue). red/blue are softened
   from pure for legibility on the dark cue background. */
#video-player::cue(.cyan) { color: #00ffff; }
#video-player::cue(.yellow) { color: #ffff00; }
#video-player::cue(.green) { color: #00ff00; }
#video-player::cue(.magenta) { color: #ff00ff; }
#video-player::cue(.red) { color: #ff6666; }
#video-player::cue(.blue) { color: #6666ff; }

/* ASS/SSA sidecar subtitles (VOD) are drawn by assjs into this overlay, which
   sits over the video plane (z-index 1) and below the OSD/menu (z-index 60).
   It matches the video's fixed 1920x1080 box so assjs aligns cues with the
   picture; pointer-events:none so it never intercepts remote/pointer input. */
#ass-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  z-index: 2;
  pointer-events: none;
}

.player-osd {
  position: absolute;
  bottom: 20px;
  left: 40px;
  right: 40px;
  background: rgba(30, 30, 50, 0.75);
  border-radius: 12px;
  padding: 16px 32px;
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  /* Blurs the picture in the desktop preview only: on the TV the video is
     its own plane under the page, so the overlay styles carry the tint. */
  backdrop-filter: var(--glass-filter);
  z-index: 60;
}

/* The OSD's buttons, one row for a movie, an episode and a channel
   (player-osd.ts buttonRow): Down from the bar reaches them, Left/Right move
   along, OK presses. Volume adjusts in place (.is-adjusting). */
.osd-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.osd-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border: 2px solid transparent;
  border-radius: 24px;
  background: var(--overlay-chip);
  color: var(--text-primary);
  font-size: calc(19px * var(--font-scale));
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.osd-button:hover,
.osd-button.focused {
  border-color: var(--accent);
  background: var(--accent);
  color: #071018;
  outline: none;
}

.osd-button-icon { display: inline-flex; width: 24px; height: 24px; }
.osd-button-icon svg { width: 24px; height: 24px; }
.osd-button-value { font-weight: 400; opacity: 0.8; }
/* The guide's and versions' icons are drawn in strokes their markup leaves
   to CSS (as in Settings' section icons); unstyled they filled black. */
.osd-button[data-osd-button="guide"] svg,
.osd-button[data-osd-button="versions"] svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A favorite channel: the star filled. */
.osd-button.is-active .osd-button-icon svg { fill: currentColor; }

/* Volume while Left/Right turn it: the value between two arrowheads. */
.osd-button.is-adjusting .osd-button-value {
  position: relative;
  padding: 0 18px;
  opacity: 1;
}
.osd-button.is-adjusting .osd-button-value::before,
.osd-button.is-adjusting .osd-button-value::after {
  content: "";
  position: absolute;
  top: 50%;
  margin-top: -6px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.osd-button.is-adjusting .osd-button-value::before { left: 0; border-right: 8px solid currentColor; }
.osd-button.is-adjusting .osd-button-value::after { right: 0; border-left: 8px solid currentColor; }

/* The volume slider for a mouse (pointer platforms, player-osd.ts): a
   track in the Volume button, out while the mouse is over it or after a
   click on it; a click or a drag along it sets the level, the wheel steps
   it, the speaker icon mutes. The TVs' OK-then-Left/Right is untouched. */
.osd-volume-track { display: none; }
html.pointer .osd-volume-track {
  display: block;
  position: relative;
  width: 0;
  height: 24px;
  padding: 9px 0;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  transition: width 0.15s ease, margin-left 0.15s ease;
}
html.pointer .osd-volume-track::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.3;
}
html.pointer .osd-button.osd-volume:hover .osd-volume-track,
html.pointer .osd-button.osd-volume.is-adjusting .osd-volume-track {
  width: 150px;
  margin-left: 8px;
}
html.pointer .osd-volume-fill {
  position: relative;
  display: block;
  height: 6px;
  border-radius: 3px;
  background: currentColor;
}
html.pointer .osd-button.is-muted .osd-volume-fill { opacity: 0.35; }
html.pointer .osd-button.osd-volume .osd-button-icon { position: relative; }
html.pointer .osd-button.is-muted .osd-button-icon::after {
  content: '';
  position: absolute;
  top: 11px;
  left: -3px;
  width: 30px;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
}
/* The slider is the affordance: no arrowheads round the value. */
html.pointer .osd-button.is-adjusting .osd-button-value { padding: 0; }
html.pointer .osd-button.is-adjusting .osd-button-value::before,
html.pointer .osd-button.is-adjusting .osd-button-value::after { display: none; }

/* The left edge opens a panel (Live's channel list): a tab shows it is
   there while the OSD is up, as on the Movies/Series column. */
.osd-edge-tab {
  position: fixed;
  top: 50%;
  left: 0;
  width: 12px;
  height: 96px;
  margin-top: -48px;
  border-radius: 0 6px 6px 0;
  background: var(--accent);
  opacity: 0.7;
  z-index: 61;
  cursor: pointer;
}

/* Player overlays use a fixed dark palette for video readability; accents still
   follow the theme. The light variant is opt-in via "Player overlay". */
.player-osd,
.player-sidebar,
.player-menu,
.episode-panel,
.subs-overlay,
.subs-offset-card,
.number-entry {
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-muted: #666680;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --border: #2a2a3e;
  --overlay-divider: rgba(255, 255, 255, 0.25);
  --overlay-chip: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

/* Frosted — opaque light glass. Cohesive with light themes; over dark video it
   reads as a bright card. */
[data-overlay="frosted"] .player-osd,
[data-overlay="frosted"] .player-sidebar,
[data-overlay="frosted"] .player-menu,
[data-overlay="frosted"] .subs-overlay,
[data-overlay="frosted"] .subs-offset-card,
[data-overlay="frosted"] .number-entry {
  background: rgba(244, 246, 249, 0.85);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --text-primary: #1f2430;
  --text-secondary: #4a5160;
  --text-muted: #79808f;
  --bg-secondary: #eceef2;
  --bg-tertiary: #dfe4ea;
  --border: #cfd5dd;
  --overlay-divider: rgba(0, 0, 0, 0.18);
  --overlay-chip: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.osd-channel {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.osd-channel-number {
  font-size: calc(42px * var(--font-scale));
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
}

.osd-channel-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
}

.osd-channel-name {
  font-size: calc(36px * var(--font-scale));
  font-weight: 600;
}

/* Which copy of the title plays ("4K-FR-HDR"), beside its name. */
.osd-version-tag {
  flex-shrink: 0;
  padding: 2px 10px;
  border: 1px solid var(--overlay-divider);
  border-radius: 6px;
  font-size: calc(18px * var(--font-scale));
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.osd-vod-dimensions {
  position: absolute;
  top: 18px;
  right: 32px;
  color: var(--text-primary);
  font-size: calc(22px * var(--font-scale));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.osd-vod-channel,
.osd-live-channel {
  padding-right: 160px;
}

.osd-stream-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 2px solid var(--overlay-divider);
}

.si-badge {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  color: #fff;
  letter-spacing: 0.5px;
}

.si-badge--uhd { background: #6c4cd6; }
.si-badge--fhd { background: #2b7de9; }
.si-badge--hd  { background: #1aa3a3; }
.si-badge--sd  { background: #5a6472; }
.si-badge--hdr { background: #c9971c; }

.si-pill {
  font-size: calc(18px * var(--font-scale));
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  background: var(--overlay-chip);
  color: var(--text-primary);
}

.si-text {
  font-size: calc(18px * var(--font-scale));
  color: var(--text-secondary);
}

.osd-programme {
  margin-top: 4px;
}

.osd-now-label {
  font-size: calc(20px * var(--font-scale));
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.osd-programme-detail {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.osd-programme-icon {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.osd-programme-info {
  flex: 1;
  min-width: 0;
}

.osd-programme-title {
  font-size: calc(30px * var(--font-scale));
  font-weight: 500;
  margin-bottom: 2px;
}

.osd-programme-time {
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
}

.osd-remaining {
  color: var(--text-muted);
  font-size: calc(22px * var(--font-scale));
}

.osd-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.osd-time-current,
.osd-time-end {
  font-size: calc(22px * var(--font-scale));
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.osd-time-current {
  color: var(--accent);
  font-weight: 600;
}

.osd-progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
}

.osd-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  border-radius: 3px;
  transition: width 1s linear;
}

/* The seek bar and, while seeking a VOD, its picture above the target. */
.osd-progress-track {
  position: relative;
  flex: 1;
  min-width: 0;
}

.osd-scrub-preview {
  position: absolute;
  bottom: 100%;
  width: 320px;
  height: 180px;
  margin-bottom: 8px;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  border: 2px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

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

.osd-progress[data-seekbar] {
  cursor: pointer;
  height: 36px;
  padding: 15px 0;
  background-clip: content-box;
  overflow: visible;
}

.osd-progress[data-seekbar] .osd-progress-bar {
  position: relative;
  overflow: visible;
  transition: width 0.12s linear;
}

.osd-progress[data-seekbar] .osd-progress-bar::after {
  content: '';
  position: absolute;
  right: -9px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Live DVR (timeshift) row: play/pause + "behind live" offset + Go-to-Live. The
   play/pause button (.osd-dvr-btn) is also used in the catch-up progress row. */
.osd-dvr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
}

.osd-dvr-btn svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Resync A/V button — reuses the play/pause icon-button sizing. */
.osd-resync-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
}

.osd-resync-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

.osd-dvr-behind {
  min-width: 72px;
}

.osd-dvr-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.osd-dvr-live::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
}

.osd-dvr-live.is-live {
  color: var(--danger);
}

.osd-dvr-live.is-live::before {
  box-shadow: 0 0 8px var(--danger);
}

.osd-description {
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.osd-next {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
}

.osd-next-label {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.osd-next-title {
  flex: 1;
}

.osd-next-time {
  color: var(--text-muted);
  margin-left: 8px;
}

.osd-message {
  font-size: calc(26px * var(--font-scale));
  color: var(--warning);
  text-align: center;
  padding: 20px;
}

.osd-next-episode {
  padding: 8px 0;
}

.osd-next-episode-label {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: calc(20px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.osd-next-episode-time {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: calc(24px * var(--font-scale));
}

.osd-next-episode-actions {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.osd-next-episode-actions button {
  padding: 10px 20px;
  border: 1px solid var(--overlay-chip);
  border-radius: 6px;
  background: var(--overlay-chip);
  color: var(--text-primary);
  font-size: calc(22px * var(--font-scale));
  cursor: pointer;
}

.osd-next-episode-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Player sidebar overlay (Magic Remote / left key) */
/* A series' episodes beside the playing one (episode-panel.ts), opened
   from the left edge as Live's channel list is. Opaque rather than blurred:
   nothing to fall back to on engines without backdrop-filter. */
.episode-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 560px;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 15, 0.95);
  border-right: 1px solid var(--border);
  color: var(--text-primary);
  z-index: 70;
}

.episode-panel-header {
  padding: 40px 32px 16px;
  font-size: calc(30px * var(--font-scale));
  font-weight: 700;
}

.episode-panel-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 16px 32px;
}

.episode-panel-season {
  padding: 20px 16px 8px;
  font-size: calc(18px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.episode-panel-row {
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: calc(22px * var(--font-scale));
  line-height: 1.3;
  cursor: pointer;
}

.episode-panel-row.is-playing { color: var(--accent); font-weight: 600; }

.episode-panel-row:hover,
.episode-panel-row.focused {
  border-color: var(--accent);
  background: rgb(255 255 255 / 0.08);
}

.player-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: fit-content;
  height: 1080px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: var(--glass-filter);
  z-index: 70;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  border-right: 1px solid var(--glass-edge);
}

.player-sidebar.hidden {
  display: flex !important;
  visibility: hidden;
}

.player-sidebar.visible.channels-only {
  transform: translateX(calc(420px - 100%));
}

.player-sidebar.visible.groups-expanded {
  transform: translateX(0);
}

.player-sidebar .sidebar-group-panel,
.player-sidebar .sidebar-channel-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.player-sidebar .sidebar-group-panel {
  width: fit-content;
  min-width: 280px;
  max-width: 440px;
  border-right: 1px solid var(--border);
}

.player-sidebar .sidebar-group-width-probe {
  width: max-content;
  height: 0;
  padding: 0 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  visibility: hidden;
  overflow: hidden;
  flex-shrink: 0;
  white-space: nowrap;
}

.player-sidebar .sidebar-group-width-probe .sidebar-group-name {
  flex: none;
}

.player-sidebar .sidebar-channel-panel {
  width: 420px;
}

.player-sidebar .sidebar-title {
  padding: 20px 24px;
  font-size: calc(24px * var(--font-scale));
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.player-sidebar .sidebar-channel-title {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  text-align: left;
  background: rgba(var(--accent-rgb-legacy), 0.06);
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 160ms ease;
}

.player-sidebar .sidebar-channel-title:hover {
  background: rgba(var(--accent-rgb-legacy), 0.12);
}

.player-sidebar .sidebar-picker-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-sidebar .sidebar-picker-arrow {
  width: 28px;
  height: 28px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 180ms ease, color 160ms ease;
}

.player-sidebar .sidebar-picker-arrow svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-sidebar.visible.channels-only .sidebar-picker-arrow svg {
  animation: group-picker-nudge 800ms ease-in-out infinite;
}

.player-sidebar.groups-expanded .sidebar-picker-arrow {
  color: var(--accent);
  transform: rotate(180deg);
}

.player-sidebar.groups-expanded .sidebar-picker-arrow svg {
  animation: none;
}

@keyframes group-picker-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}

.player-sidebar .sidebar-group-list {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.player-sidebar .sidebar-group-spacer {
  position: relative;
}

.player-sidebar .sidebar-group-item {
  position: absolute;
  left: 0;
  right: 0;
  height: 64px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

/* A simple category, indented under its region. */
.player-sidebar .sidebar-group-item.sidebar-group-nested {
  padding-left: 34px;
}

.player-sidebar .sidebar-group-item.active {
  background: rgba(var(--accent-rgb-legacy), 0.1);
  border-color: var(--accent-dim);
}

.player-sidebar .sidebar-group-item.focused {
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
}

.player-sidebar .sidebar-group-item.active.focused {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb-legacy), 0.2);
}

.player-sidebar .sidebar-group-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: calc(22px * var(--font-scale));
  color: var(--accent);
  background: transparent;
}

.player-sidebar .sidebar-group-icon .group-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.player-sidebar .sidebar-group-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: calc(22px * var(--font-scale));
  color: var(--text-primary);
}

.player-sidebar .sidebar-group-count {
  min-width: 32px;
  padding: 2px 6px;
  color: var(--text-secondary);
  background: var(--overlay-chip);
  border-radius: 10px;
  font-size: calc(16px * var(--font-scale));
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-sidebar .sidebar-search-input {
  margin: 12px;
  padding: 18px 16px;
  font-size: calc(28px * var(--font-scale));
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
  text-overflow: ellipsis;
  transition: var(--transition);
  flex-shrink: 0;
}

.player-sidebar .sidebar-search-input::placeholder {
  color: var(--text-muted);
}

.player-sidebar .sidebar-search-input.focused,
.player-sidebar .sidebar-search-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
}

.player-sidebar .sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.player-sidebar .sidebar-tab {
  padding: 8px 14px;
  font-size: calc(16px * var(--font-scale));
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.player-sidebar .sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

.player-sidebar .sidebar-tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.player-sidebar .sidebar-channel-list {
  display: block;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
}

.player-sidebar .sidebar-channel-spacer {
  position: relative;
  width: 100%;
}

/* Fixed height: the channel list is virtualized, so CHANNEL_ROW_STRIDE in
   sidebar.ts must stay this height plus the 4px row gap. The two text lines
   only just fit, so check this box before growing either font. */
.player-sidebar .sidebar-ch-item {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  gap: 14px;
  height: 84px;
  flex-shrink: 0;
}

.player-sidebar .sidebar-ch-item.playing {
  background: rgba(var(--accent-rgb-legacy), 0.1);
  border-color: var(--accent-dim);
}

.player-sidebar .sidebar-ch-item.focused {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--text-primary);
}

.player-sidebar .sidebar-ch-item.playing.focused {
  background: rgba(var(--accent-rgb-legacy), 0.2);
  border-color: var(--accent);
}

.player-sidebar .sidebar-ch-item .ch-num {
  font-size: calc(16px * var(--font-scale));
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-sidebar .sidebar-ch-item .ch-logo-wrap {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-sidebar .sidebar-ch-item .ch-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}

.player-sidebar .sidebar-ch-item .ch-logo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(20px * var(--font-scale));
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.player-sidebar .sidebar-ch-item .ch-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-sidebar .sidebar-ch-item .ch-name {
  font-size: calc(24px * var(--font-scale));
  line-height: 1.25;
  overflow: hidden;
  white-space: nowrap;
}

.player-sidebar .sidebar-ch-item .ch-now {
  font-size: calc(18px * var(--font-scale));
  line-height: 1.25;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
}

.player-sidebar .sidebar-ch-item .ch-name .ch-name-text,
.player-sidebar .sidebar-ch-item .ch-now .ch-now-text {
  display: inline-block;
  white-space: nowrap;
}

.player-sidebar .sidebar-ch-item .ch-name .ch-name-text.scrolling,
.player-sidebar .sidebar-ch-item .ch-now .ch-now-text.scrolling {
  animation: marquee-bounce 6s ease-in-out infinite;
}

.player-sidebar .sidebar-recent-kind {
  flex-shrink: 0;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
}

@keyframes marquee-bounce {
  0%, 15% { transform: translateX(0); }
  45%, 55% { transform: translateX(var(--scroll-dist)); }
  85%, 100% { transform: translateX(0); }
}

/* Player right menu (Magic Remote / right key) */
.player-menu {
  position: absolute;
  top: 0;
  right: 0;
  width: fit-content;
  min-width: 340px;
  max-width: 440px;
  height: 1080px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: var(--glass-filter);
  z-index: 70;
  display: flex;
  flex-direction: column;
  padding: 24px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  border-left: 1px solid var(--glass-edge);
}

.player-menu.visible {
  transform: translateX(0);
}

.player-menu .menu-header {
  margin-bottom: 32px;
}

.player-menu .menu-header h2 {
  font-size: calc(28px * var(--font-scale));
  color: var(--accent);
}

.player-menu .menu-header .menu-subtitle {
  font-size: calc(18px * var(--font-scale));
  color: var(--text-muted);
  margin-top: 4px;
}

.player-menu .menu-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;            /* fill the remaining height of the fixed-height panel */
  min-height: 0;      /* allow the flex child to shrink so overflow-y can scroll */
  overflow-y: auto;   /* long track lists scroll instead of running off-screen */
}

.player-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-size: calc(22px * var(--font-scale));
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap; /* keep a row's label on one line; the value chip ellipsizes instead */
}

.player-menu .menu-item.focused {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--text-primary);
}

.player-menu .menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

.menu-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.menu-dot.red { background: var(--remote-key-red); }
.menu-dot.green { background: var(--remote-key-green); }
.menu-dot.yellow { background: var(--remote-key-yellow); }
.menu-dot.blue { background: var(--remote-key-blue); }

/* Glyph in the color-dot slot */
.menu-icon {
  width: 14px;
  flex-shrink: 0;
  text-align: center;
  font-size: calc(18px * var(--font-scale));
  line-height: 1;
}
.menu-icon.audio { color: #9b59b6; }
.menu-icon.subtitle {
  color: #1abc9c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.menu-icon.subtitle svg { display: block; width: 18px; height: 18px; }

/* Current audio track shown on the "Audio Track" row */
.player-menu .menu-item-value {
  margin-left: auto;
  padding-left: 12px;
  font-size: calc(16px * var(--font-scale));
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* allow the chip to shrink (and ellipsize) so the label keeps its line */
  max-width: 140px;
}

/* Fixed check / chevron column in the audio sub-menu so labels align */
.player-menu .menu-check {
  width: 18px;
  flex-shrink: 0;
  text-align: center;
  color: #2ecc71;
  font-weight: 700;
}

.player-menu .menu-check.menu-back {
  color: var(--text-primary);
  font-size: calc(26px * var(--font-scale));
  line-height: 1;
}

.player-menu .menu-track-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-menu .menu-item.unavailable {
  opacity: 0.4;
}

/* Online files not downloaded yet: quieter, with a small cloud */
.player-menu .menu-item.menu-online .menu-track-label,
.player-menu .menu-item.menu-more .menu-track-label {
  color: var(--text-secondary);
}
.player-menu .menu-item.menu-online.focused .menu-track-label,
.player-menu .menu-item.menu-more.focused .menu-track-label {
  color: var(--text-primary);
}
.player-menu .menu-online-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.player-menu .menu-online-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.player-menu .menu-item.unavailable.focused {
  opacity: 0.6;
}

/* Subtitle search overlay — centered modal over the player */
.subs-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  width: 1100px;
  max-height: 600px;
  background: rgba(30, 30, 50, 0.95);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 70;
}

.subs-overlay-header {
  flex: none;
  font-size: calc(32px * var(--font-scale));
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.subs-search-input {
  flex: none;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: calc(24px * var(--font-scale));
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: 8px;
  outline: none;
}

.subs-search-input:focus {
  border-color: var(--accent);
}

.subs-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.subs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: calc(22px * var(--font-scale));
  color: var(--text-secondary);
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
}

.subs-row-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.subs-count {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  font-size: calc(18px * var(--font-scale));
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.subs-count svg {
  width: 16px;
  height: 16px;
}

.subs-row.focused {
  background: var(--accent-dim);
  color: #fff;
  box-shadow: none !important;
}

.subs-row.focused .subs-count {
  color: #fff;
}

.subs-status {
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
  text-align: center;
}

#subtitle-offset {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
}

.subs-offset-card {
  pointer-events: auto;
  min-width: 360px;
  padding: 32px 40px;
  border-radius: 12px;
  background: rgba(30, 30, 50, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.subs-offset-title {
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.subs-offset-value {
  font-size: calc(56px * var(--font-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}

/* Which way to press, in words: a number alone doesn't say whether more
   means earlier or later. */
.subs-offset-guide {
  font-size: calc(20px * var(--font-scale));
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.subs-offset-hint {
  font-size: calc(18px * var(--font-scale));
  color: var(--text-muted);
  margin: 14px 0 20px;
}

.subs-offset-reset {
  display: inline-block;
  padding: 10px 28px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: calc(20px * var(--font-scale));
}

.subs-offset-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.subs-offset-prompt {
  font-size: calc(24px * var(--font-scale));
  color: var(--text-primary);
  margin: 12px 0;
}

/* The listening card stays small and low: the viewer is watching for the
   moment a line starts. */
.subs-offset-listen {
  min-width: 0;
  max-width: 640px;
}

.subs-offset-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 4px;
  text-align: left;
}

.subs-offset-line {
  max-width: 720px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  font-size: calc(22px * var(--font-scale));
}

.subs-offset-line.focused,
.subs-offset-line:hover,
.subs-offset-reset.focused,
.subs-offset-reset:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.confirmation-prompt.episode-next-prompt {
  background: transparent;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
  padding: 48px;
}

.episode-next-prompt .confirmation-dialog { width: 540px; pointer-events: auto; }
.episode-next-prompt .confirmation-btn.danger { color: var(--text-primary); }

.menu-volume { display: block; }
.volume-slider { height: 12px; margin-top: 12px; background: rgba(255, 255, 255, 0.25); border-radius: 6px; }
.volume-slider > div { height: 100%; background: var(--accent); border-radius: 6px; }

/* The small print under "Subtitles aren't ready yet": why waiting pays. */
.subtitle-wait-prompt .subtitle-wait-why {
  font-size: 0.8em;
  opacity: 0.75;
}
