/* ===================================================
   DGM — YouTube TV UI
   =================================================== */

:root {
  --nav-h: 68px;
  --bg: #0f0f0f;
  --nav-bg: #212121;
  --surface: #272727;
  --surface-2: #1a1a1a;
  --ink: #f1f1f1;
  --ink-muted: #aaaaaa;
  --brand: #ff0000;
  --focus-ring: #ffffff;
  --card-radius: 4px;
  --page-pad: 40px;
  --nav-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  --font-body: "Inter", "Segoe UI", Arial, sans-serif;
  --font-heading: "Ubuntu", "Inter", "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Headline font for real headings only — card titles stay on the body font */
.section-title,
.settings-modal-title,
.playlist-bar-title,
#channelTitle,
.tv-logo span {
  font-family: var(--font-heading);
}

[hidden] {
  display: none !important;
}

/* =============================================
   TV Navigation Bar
   ============================================= */

.tv-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 var(--page-pad);
  z-index: 200;
  box-shadow: var(--nav-shadow);
}

/* Logo */
.tv-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.tv-logo span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tv-logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.tv-logo svg {
  height: 36px;
  width: auto;
  display: block;
}

/* Search form */
.search-form {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  max-width: 640px;
}

.search-field {
  display: flex;
  align-items: center;
  flex: 1;
  background: #121212;
  border: 1px solid #383838;
  border-right: none;
  border-radius: 2px 0 0 2px;
  padding: 0 14px;
  height: 40px;
  transition: border-color 150ms;
}

.search-field:focus-within {
  border-color: #909090;
}

.search-icon {
  color: var(--ink-muted);
  flex-shrink: 0;
  margin-right: 10px;
}

.search-field input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 0;
  min-width: 0;
}

.search-field input::placeholder {
  color: #717171;
}

/* Hide native clear button; replaced with custom .search-clear-btn */
.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-clear-btn {
  background: rgba(255, 255, 255, 0.08) !important;
}

.search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.18) !important;
}

.voice-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 6px;
  margin-left: 6px;
  border-radius: 50%;
  transition: color 140ms, background 140ms;
  flex-shrink: 0;
}

.voice-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.voice-btn.is-listening {
  color: var(--brand);
  background: rgba(255, 0, 0, 0.12);
}

.voice-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.search-submit-btn {
  height: 40px;
  padding: 0 22px;
  background: #303030;
  color: var(--ink);
  border: 1px solid #383838;
  border-radius: 0 2px 2px 0;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 140ms;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-submit-btn:hover {
  background: #404040;
}

.search-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tv-status {
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin: 0;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  padding-left: 12px;
  border-left: 1px solid #383838;
}

/* =============================================
   Nav menu
   ============================================= */

.nav-settings-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.menu-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
  padding: 0;
}

.menu-btn:hover,
.menu-btn[aria-expanded="true"] {
  background: var(--surface);
  border-color: #555;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  background: #282828;
  border: 1px solid #383838;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7);
  z-index: 500;
  overflow: hidden;
  animation: dropdown-in 140ms ease both;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  transition: background 120ms;
}

.nav-item:hover {
  background: #383838;
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--ink-muted);
}

.nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

/* =============================================
   Settings modal
   ============================================= */

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal[hidden] {
  display: none !important;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.settings-modal-box {
  position: relative;
  background: #282828;
  border: 1px solid #383838;
  border-radius: 10px;
  width: min(400px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: modal-in 180ms ease both;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.settings-modal-head {
  display: flex;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #383838;
  gap: 12px;
}

.settings-modal-title {
  margin: 0;
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.settings-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 140ms, color 140ms;
  flex-shrink: 0;
  padding: 0;
}

.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.settings-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 120ms;
  box-sizing: border-box;
}

.settings-row:hover {
  background: #383838;
}

.settings-row svg {
  flex-shrink: 0;
  color: var(--ink-muted);
}

.settings-row-text {
  flex: 1;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #555;
  border-radius: 20px;
  transition: background 200ms;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 200ms;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--brand);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* Watched video badge */
.result-card.is-watched::before {
  content: 'Watched';
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.72);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--card-radius) 0 4px 0;
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}

/* =============================================
   Light mode theme
   ============================================= */

body.is-light {
  --bg: #f9f9f9;
  --nav-bg: #ffffff;
  --surface: #efefef;
  --surface-2: #e5e5e5;
  --ink: #0f0f0f;
  --ink-muted: #606060;
  --focus-ring: #222222;
  --nav-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.is-light .search-field {
  background: #ffffff;
  border-color: #d0d0d0;
}

body.is-light .search-submit-btn {
  background: #e8e8e8;
  border-color: #d0d0d0;
}

body.is-light .nav-dropdown {
  background: #ffffff;
  border-color: #e0e0e0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

body.is-light .nav-item:hover,
body.is-light .settings-row:hover {
  background: #f0f0f0;
}

body.is-light .settings-modal-box {
  background: #ffffff;
  border-color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

body.is-light .settings-modal-head {
  border-bottom-color: #e0e0e0;
}

body.is-light .toggle-slider {
  background: #c0c0c0;
}

body.is-light .ghost-btn {
  border-color: #d0d0d0;
}

body.is-light .ghost-btn:hover {
  background: #efefef;
  border-color: #b0b0b0;
}

body.is-light .channel-profile {
  border-bottom-color: #e0e0e0;
}

body.is-light .channel-card-avatar {
  background: #d0d0d0;
}

body.is-light .subscribe-btn {
  color: #ffffff;
}

body.is-light .subscribe-btn.is-subscribed {
  background: #e0e0e0;
  color: #0f0f0f;
}

body.is-light .result-card img {
  background: #e0e0e0;
}

body.is-light .result-card:hover,
body.is-light .result-card:focus {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

body.is-light .home-link:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: #999;
}

body.is-light .tv-logo-img,
body.is-light .home-logo-img {
  filter: invert(1);
}

body.is-light .page-btn {
  background: #e8e8e8;
  border-color: #d0d0d0;
  color: #0f0f0f;
}

body.is-light .page-btn:hover {
  background: #d8d8d8;
}

body.is-light .menu-btn {
  border-color: #d0d0d0;
  color: #0f0f0f;
}

body.is-light .menu-btn:hover,
body.is-light .menu-btn[aria-expanded="true"] {
  background: #efefef;
  border-color: #b0b0b0;
}

/* =============================================
   Subscribe button
   ============================================= */

.channel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.subscribe-btn {
  padding: 10px 22px;
  background: var(--ink);
  color: #0f0f0f;
  border: 0;
  border-radius: 2px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms, color 140ms;
  letter-spacing: 0.02em;
}

.subscribe-btn:hover {
  background: #d0d0d0;
}

.subscribe-btn.is-subscribed {
  background: #3a3a3a;
  color: var(--ink);
}

.subscribe-btn.is-subscribed:hover {
  background: #cc0000;
  color: #fff;
}

/* =============================================
   Subscriptions channels grid
   ============================================= */

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.channel-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  text-align: center;
  outline: none;
  transition: transform 160ms ease, border-color 160ms ease;
  animation: card-in 260ms ease both;
  animation-delay: calc(var(--idx) * 28ms);
}

.channel-card:hover,
.channel-card:focus {
  transform: scale(1.05);
  border-color: var(--focus-ring);
}

.channel-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: #3a3a3a;
  flex-shrink: 0;
}

.channel-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-card-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--ink-muted);
}

.channel-card h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

.channel-card .unsubscribe-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity 140ms, background 140ms;
  padding: 0;
}

.channel-card:hover .unsubscribe-btn,
.channel-card:focus .unsubscribe-btn {
  opacity: 1;
}

.channel-card .unsubscribe-btn:hover {
  background: var(--brand);
}

.channel-results-row {
  margin-bottom: 48px;
}

/* Playlists row sits below the video pagination — give it breathing room. */
#playlistResultsRow {
  margin-top: 56px;
}

.channel-card-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

.channel-card-subs {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* =============================================
   Main content area
   ============================================= */

/* =============================================
   Home screen
   ============================================= */

.home-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.home-screen[hidden] {
  display: none;
}

.home-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  width: 100%;
  max-width: 640px;
  padding: 0 24px;
}

.home-logo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-logo-img {
  height: 44px;
  width: auto;
}

.home-search-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.home-search-field {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 14px 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.home-search-field:focus-within {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus-ring) 25%, transparent);
}

.home-search-field .search-icon {
  color: var(--ink-muted);
  flex-shrink: 0;
}

.home-search-field input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 1.05rem;
  font-family: inherit;
}

.home-search-field input::placeholder {
  color: var(--ink-muted);
}

.home-search-field input::-webkit-search-cancel-button {
  display: none;
}

.home-search-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 36px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.home-search-btn:hover {
  opacity: 0.85;
}

.home-links {
  display: flex;
  gap: 12px;
}

.home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 8px 18px;
  cursor: pointer;
  transition: border-color 140ms, color 140ms, background 140ms;
}

.home-link:hover {
  border-color: #666;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

/* Hide header on home screen */
body.is-home .tv-nav {
  display: none;
}

body.is-home .tv-content {
  margin-top: 0;
}

/* =============================================
   Main content area
   ============================================= */

.tv-content {
  margin-top: var(--nav-h);
  padding: 36px var(--page-pad) 72px;
  min-height: calc(100vh - var(--nav-h));
  scroll-padding-top: calc(var(--nav-h) + 20px);
}

/* =============================================
   Sections
   ============================================= */

.tv-section {
  scroll-margin-top: calc(var(--nav-h) + 20px);
  margin-bottom: 56px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
  letter-spacing: 0.01em;
}

.videos-heading {
  margin-top: 36px;
}

/* =============================================
   TV Video Grid
   ============================================= */

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px 16px;
}

/* =============================================
   Video Card
   ============================================= */

.result-card {
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--card-radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  outline: none;
  position: relative;
  transition: transform 180ms cubic-bezier(0.2, 0, 0.2, 1),
              border-color 180ms ease,
              box-shadow 180ms ease;
  animation: card-in 260ms ease both;
  animation-delay: calc(var(--idx) * 28ms);
}

.result-card:hover,
.result-card:focus {
  transform: scale(1.05);
  border-color: var(--focus-ring);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  z-index: 10;
}

/* Thumbnail */
.result-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--card-radius);
  background: #1a1a1a;
  display: block;
}

/* Title */
.result-card h3 {
  margin: 10px 0 4px;
  font-size: 0.95rem;
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Channel / date */
.result-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-card p + p {
  margin-top: 2px;
}

/* Bookmark action overlay */
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 160ms;
}

.result-card:hover .card-actions,
.result-card:focus .card-actions {
  opacity: 1;
}

.bookmark-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 130ms;
}

.bookmark-btn:hover {
  background: rgba(30, 30, 30, 0.95);
}

.bookmark-btn.is-saved {
  background: var(--brand);
}

/* =============================================
   Pagination
   ============================================= */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 44px;
}

.pagination[hidden] {
  display: none;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 150px;
  padding: 10px 26px;
  background: #272727;
  color: var(--ink);
  border: 1px solid #383838;
  border-radius: 2px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 130ms;
}

.page-btn:hover {
  background: #383838;
}

.page-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.page-summary {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin: 0;
  min-width: 70px;
  text-align: center;
}

/* =============================================
   Ghost / utility buttons
   ============================================= */

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid #383838;
  border-radius: 2px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 130ms, color 130ms, border-color 130ms;
}

.ghost-btn:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: #555;
}

.back-btn {
  margin-top: 14px;
  display: inline-block;
}

/* =============================================
   Channel profile
   ============================================= */

.channel-profile {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  padding: 28px 0 24px;
  border-bottom: 1px solid #272727;
  margin-bottom: 4px;
}

.channel-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}

.channel-info h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.channel-bio {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin: 8px 0 0;
  max-width: 640px;
  line-height: 1.55;
}

/* ── Channel tabs (Videos / Playlists) ── */
.channel-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0 4px;
  border-bottom: 1px solid #272727;
}

.channel-tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.channel-tab:hover {
  color: var(--ink);
}

.channel-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--brand);
}

/* ── Playlist header bar (when viewing a single playlist's videos) ── */
.playlist-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0px 40px;
}

.playlist-bar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Playlist count badge on playlist cards ── */
.result-card .playlist-count {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  pointer-events: none;
}

/* ── Video duration badge on thumbnails ── */
.card-thumb {
  position: relative;
  display: block;
  line-height: 0;
}

.card-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ── Player next/previous ── */
.player-icon-btn[disabled] {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* =============================================
   Video player (full-screen overlay)
   ============================================= */

.player-section {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: flex;
  flex-direction: column;
}

.player-section[hidden] {
  display: none !important;
}

/* Staged state: invisible while requesting fullscreen */
.player-section.is-staged {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* Fullscreen state */
.player-section.is-fullscreen,
.player-section:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.player-head {
  position: absolute;
  top: 12px;
  left: 23px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  z-index: 10;
  max-width: calc(100% - 36px);
  width: 100%;
}

.player-controls-group {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: player-controls-fade 160ms ease;
}

.player-controls-group[hidden] {
  display: none !important;
}

.player-toggle-btn {
  flex-shrink: 0;
}

.player-toggle-icon {
  display: block;
  transition: transform 180ms ease;
  pointer-events: none;
}

.player-head.is-open .player-toggle-icon {
  transform: rotate(180deg);
}

@keyframes player-controls-fade {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.player-icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 140ms, border-color 140ms;
  padding: 0;
}

.player-icon-btn:hover {
  background: rgba(40, 40, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.4);
}

.player-icon-btn.is-saved {
  background: var(--brand);
  border-color: var(--brand);
}

.player-wrap {
  flex: 1;
  position: relative;
  background: #000;
}

#playerFrame {
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  letter-spacing: 0.02em;
}

/* =============================================
   Empty state
   ============================================= */

.empty-state {
  color: var(--ink-muted);
  padding: 56px 0;
  text-align: center;
  font-size: 1rem;
  margin: 0;
  grid-column: 1 / -1;
  width: 100%;
}

/* =============================================
   Animations
   ============================================= */

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================
   Responsive — tablet
   ============================================= */

@media (max-width: 900px) {
  :root {
    --page-pad: 20px;
  }

  .tv-status {
    display: none;
  }

  .tv-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 12px;
  }
}

/* =============================================
   Responsive — mobile
   ============================================= */

@media (max-width: 600px) {
  :root {
    --page-pad: 14px;
  }

  .tv-nav {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 10px;
  }

  .tv-content {
    margin-top: 118px;
    padding-top: 20px;
  }

  .search-form {
    order: 10;
    flex: 0 0 100%;
    max-width: none;
  }

  .search-submit-btn {
    padding: 0 16px;
    min-height: auto!important;
  }

  .tv-logo span {
    font-size: 1.1rem;
  }

  .tv-status {
    display: none;
  }

  .tv-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px 10px;
  }

  .channel-profile {
    flex-direction: column;
    gap: 14px;
  }

  .pagination {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }

  .page-btn {
    flex: 1 1 auto;
    min-width: 110px;
    max-width: 160px;
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .page-summary {
    flex: 0 0 100%;
    text-align: center;
    order: -1;
  }
}

/* =============================================
   TV / large screen (1920px+)
   ============================================= */

@media (min-width: 1600px) {
  :root {
    --nav-h: 76px;
    --page-pad: 60px;
    font-size: 17px;
  }

  .tv-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px 20px;
  }
}

/* =============================================
   Pointer: coarse (touch / TV remote)
   ============================================= */

@media (pointer: coarse) {
  .result-card {
    min-height: 0;
  }

  .result-card:hover {
    transform: none;
    border-color: transparent;
    box-shadow: none;
  }

  .result-card:focus {
    transform: scale(1.04);
    border-color: var(--focus-ring);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  }

  .card-actions {
    opacity: 1;
  }

  .page-btn,
  .ghost-btn,
  .search-submit-btn {
    min-height: 48px;
  }
}
