:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-muted: #666680;
  --accent: #00d4ff;
  --accent-dim: #0088aa;
  --accent-rgb: 0 212 255;
  --accent-rgb-legacy: 0, 212, 255;
  --accent-glow: rgba(var(--accent-rgb-legacy), 0.3);
  --channel-health-healthy: #63d89b;
  --channel-health-suspect: #f3c969;
  --channel-health-unavailable: #ef7b7b;
  --danger: #ff4757;
  --danger-rgb: 255 71 87;
  --danger-rgb-legacy: 255, 71, 87;
  --success: #2ed573;
  --warning: #ffa502;
  --warning-rgb: 255 165 2;
  --warning-rgb-legacy: 255, 165, 2;
  --remote-key-red: #e74c3c;
  --remote-key-green: #2ecc71;
  --remote-key-yellow: #f1c40f;
  --remote-key-blue: #3498db;
  --border: #2a2a3e;
  --catalog-surface: #14161c;
  --catalog-control: #23262f;
  --catalog-focus: #5b8cff;
  --catalog-focus-rgb: 91 140 255;
  --catalog-focus-rgb-legacy: 91, 140, 255;
  --catalog-hero-scrim-rgb: 10 10 15;
  --catalog-hero-scrim-rgb-legacy: 10, 10, 15;
  --focus-ring: var(--accent);
  --radius: 8px;
  --transition: 0.2s ease;
  --font-scale: 1;
  /* Glass: panels, menus and dialogs over content show it frosted. Each
     theme sets its own tint (its card colour, part strength) and edge
     (css/themes.css); these are the fallbacks. */
  --glass-tint: rgba(22, 33, 62, 0.5);
  --glass-tint-solid: rgba(22, 33, 62, 0.96);
  --glass-edge: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.1);
  --glass-accent: rgba(0, 212, 255, 0.6);
  --glass-accent-solid: #00d4ff;
  --glass-filter: blur(24px) saturate(150%);
  --glass-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

/* Settings > Glass effects off: solid panels, nothing blurred. Beats the
   theme blocks' tint on specificity. */
html[data-glass="off"] {
  --glass-tint: var(--glass-tint-solid);
  --glass-accent: var(--glass-accent-solid);
  --glass-filter: none;
}

.channel-health-status {
  color: var(--text-muted);
}

.channel-health-status.healthy {
  color: var(--channel-health-healthy);
}

.channel-health-status.suspect {
  color: var(--channel-health-suspect);
}

.channel-health-status.unavailable {
  color: var(--channel-health-unavailable);
}

.channel-health-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: currentColor;
  border-radius: 50%;
}

/* App-wide font size. The ids are percentages (see TEXT_SIZES in
   src/config/themes.ts); 100 uses the default multiplier above. */
[data-text-size="80"] { --font-scale: 0.8; }
[data-text-size="90"] { --font-scale: 0.9; }
[data-text-size="110"] { --font-scale: 1.1; }
[data-text-size="120"] { --font-scale: 1.2; }
[data-text-size="130"] { --font-scale: 1.3; }
[data-text-size="140"] { --font-scale: 1.4; }
[data-text-size="150"] { --font-scale: 1.5; }

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  font-family: -apple-system, 'LG Smart UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: calc(24px * var(--font-scale));
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
}

.hidden {
  display: none !important;
}

h2 {
  font-size: calc(32px * var(--font-scale));
  font-weight: 600;
  color: var(--text-primary);
}

h3 {
  font-size: calc(26px * var(--font-scale));
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Loading */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 24px;
}

.loading-spinner {
  width: 64px;
  height: 64px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Buttons */
button:not(:disabled):not(.account-avatar):not(.toggle-option):not(.source-toggle):not(.epg-reminder-entry) {
  transform-origin: center;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition),
    color var(--transition);
}

button:not(:disabled):not(.account-avatar):not(.toggle-option):not(.source-toggle):not(.epg-reminder-entry):hover,
button:not(:disabled):not(.account-avatar):not(.toggle-option):not(.source-toggle):not(.epg-reminder-entry).focused {
  transform: scale(1.03);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  font-size: calc(22px * var(--font-scale));
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: white;
}

.btn-danger {
  background: rgba(var(--danger-rgb-legacy), 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-large {
  padding: 14px 40px;
  font-size: calc(26px * var(--font-scale));
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--glass-tint);
  backdrop-filter: var(--glass-filter);
  color: var(--text-primary);
  padding: 14px 32px;
  border-radius: var(--radius);
  font-size: calc(24px * var(--font-scale));
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Direct channel entry: the digits typed so far, echoed until they tune. */
.number-entry {
  position: fixed;
  top: 108px;
  right: 64px;
  padding: 20px 26px 16px;
  /* Same surface as the player OSD (palette in player.css), which it shares the
     screen with; `[data-overlay]` swaps both to frosted at once. */
  background: rgba(30, 30, 50, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 18px var(--accent-glow);
  text-align: center;
  opacity: 0;
  transform: translateY(-12px) scale(0.94);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
  pointer-events: none;
}

.number-entry.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.number-entry-digits {
  display: block;
  white-space: nowrap;
}

.number-entry-digit {
  display: inline-block;
  min-width: 42px;
  padding: 4px 0;
  color: var(--text-primary);
  font-size: calc(68px * var(--font-scale));
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 18px var(--accent-glow);
  animation: number-entry-pop 0.22s ease-out;
}

/* Runs down as the entry debounce does, so the wait before it tunes is visible. */
.number-entry-countdown {
  display: block;
  overflow: hidden;
  height: 4px;
  margin-top: 14px;
  background: var(--border);
  border-radius: 2px;
}

.number-entry-countdown-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  animation: number-entry-countdown linear forwards;
}

/* Transform only: animating opacity left the glyph painted faded once it ended. */
@keyframes number-entry-pop {
  from {
    transform: translateY(6px) scale(0.6);
  }

  to {
    transform: translateY(0) scale(1);
  }
}

@keyframes number-entry-countdown {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}


/* Empty state */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
  font-size: calc(28px * var(--font-scale));
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#video-player {
  position: fixed;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  z-index: 1;
  background: black;
  object-fit: contain;
  display: none;
}

#video-player.active {
  display: block;
}

/* Live browse mini-player: geometry is set inline from the preview slot. */
#video-player.mini {
  z-index: 40;
  object-fit: contain;
  transform: none;
  border-radius: 8px;
  background: #000;
  /* Clicks hit the focusable slot underneath (fullscreen / versions). */
  pointer-events: none;
}

/* Mini ↔ fullscreen: animate the same element between slot and full-bleed. */
#video-player.mini.mini-expanding {
  z-index: 55;
  pointer-events: none;
  transition:
    top 280ms ease-out,
    left 280ms ease-out,
    width 280ms ease-out,
    height 280ms ease-out,
    border-radius 280ms ease-out;
}

#video-player.aspect-force-16x9 { object-fit: fill; }
#video-player.aspect-force-4x3 {
  left: 240px;
  width: 1440px;
  object-fit: fill;
}
#video-player.aspect-crop {
  object-fit: cover;
  transform: scale(1.33);
  transform-origin: center;
}

/* Program-reminder & catch-up resume prompts — overlay modals */
.reminder-prompt,
.catchup-resume-prompt,
.confirmation-prompt {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
}
.reminder-prompt.hidden,
.catchup-resume-prompt.hidden,
.confirmation-prompt.hidden {
  display: none;
}

.reminder-dialog,
.catchup-resume-dialog,
.confirmation-dialog {
  background: var(--glass-tint);
  backdrop-filter: var(--glass-filter);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--glass-shadow);
  border-radius: var(--radius);
  padding: 40px 48px;
  max-width: 720px;
  text-align: center;
}

.reminder-message,
.catchup-resume-message,
.confirmation-message {
  color: var(--text-primary);
  font-size: calc(30px * var(--font-scale));
  margin: 0 0 32px;
}

.reminder-buttons,
.catchup-resume-buttons,
.confirmation-buttons {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.reminder-btn,
.catchup-resume-btn,
.confirmation-btn {
  min-width: 160px;
  padding: 14px 32px;
  font-size: calc(26px * var(--font-scale));
  color: var(--text-primary);
  background: transparent;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.reminder-btn.focused,
.catchup-resume-btn.focused,
.confirmation-btn.focused {
  border-color: var(--focus-ring);
  background: var(--accent-dim);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.confirmation-title {
  margin: 0 0 16px;
  font-size: calc(34px * var(--font-scale));
}

.confirmation-btn.danger {
  color: var(--danger);
}

/* The parental PIN (pin-prompt.ts): four dots, then a keypad for a remote
   without number keys. */
.pin-dialog { width: 520px; }
.pin-message {
  min-height: 1.4em;
  margin: 0 0 20px;
  font-size: calc(24px * var(--font-scale));
  color: var(--text-secondary);
}
.pin-message.is-refused { color: var(--danger); }
.pin-dots {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.pin-dots > * + * { margin-left: 20px; }
.pin-dot {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  box-sizing: border-box;
}
.pin-dot.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}
/* Flex, not grid: Chromium 53 (webOS 4) has no grid. */
.pin-keypad {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.pin-key {
  width: 132px;
  min-width: 0;
  margin-bottom: 14px;
  padding: 12px 0;
  font-size: calc(30px * var(--font-scale));
}
.pin-key[data-pin-key="cancel"] { font-size: calc(22px * var(--font-scale)); }
.pin-key svg { width: 30px; height: 30px; vertical-align: middle; }

/* EPG reminder bell badge — dim on any future program (affordance), accent once set */
.epg-bell-glyph {
  width: 22px;
  height: 22px;
  vertical-align: -3px;
}
.epg-prog-title .epg-bell-glyph { margin-left: 8px; }
.epg-bell-glyph.unset { color: var(--text-muted); opacity: 0.5; }
.epg-bell-glyph.set {
  color: var(--warning);
  filter: drop-shadow(0 0 4px rgba(var(--warning-rgb-legacy), 0.5));
}
