:root {
  color-scheme: dark;
  --fg: #e7e7ea;
  --bg: #0c0d10;
  --accent: #6cf;
  --muted: #9aa0aa;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
}
header {
  display: flex; align-items: baseline; gap: 1rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid #1f2025;
}
header h1 { margin: 0; font-size: 1.25rem; color: var(--accent); }
.badge {
  font-family: monospace; font-size: .85rem;
  padding: .2rem .5rem; border-radius: .25rem;
  background: #1f2025; color: var(--muted);
}
.badge[data-state="active"] { background: #073; color: #cfe; }
.badge[data-state="degraded"] { background: #730; color: #fce; }

main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  padding: 1rem 2rem;
}
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

video { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: .5rem; }

aside { font-size: .9rem; }
aside h2 { font-size: 1rem; color: var(--muted); margin: 1rem 0 .5rem; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-family: monospace; }

form { display: grid; gap: .5rem; }
form label { display: grid; gap: .25rem; }
form input {
  background: #1f2025; color: var(--fg); border: 1px solid #2a2c33;
  padding: .35rem .5rem; border-radius: .25rem; font: inherit;
}
form button {
  background: var(--accent); color: #001; border: 0;
  padding: .5rem; border-radius: .25rem; cursor: pointer; font-weight: 600;
}

/* Now-playing EPG (now/next) shown under the channel picker. */
.now-playing {
  margin: .35rem 0 .25rem;
  padding: .4rem .55rem;
  background: #1f2025;
  border-left: 3px solid var(--accent);
  border-radius: .25rem;
  font-size: .85rem;
  line-height: 1.35;
}
.now-playing .np-now { color: var(--accent); font-weight: 600; }
.now-playing .np-next { color: var(--muted); font-weight: 600; }
.now-playing .np-time { color: var(--muted); }

/* Content search + favorites filter rows (channels + VOD). */
.filter-row { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.filter-row .search-input {
  flex: 1; min-width: 0;
  background: #1f2025; color: var(--fg); border: 1px solid #2a2c33;
  padding: .35rem .5rem; border-radius: .25rem; font: inherit;
}
.filter-row .fav-btn {
  background: #1f2025; color: var(--accent); border: 1px solid #2a2c33;
  padding: .35rem .5rem; border-radius: .25rem; cursor: pointer; line-height: 1;
}
.filter-row .fav-only {
  display: inline-flex; align-items: center; gap: .2rem;
  color: var(--accent); cursor: pointer; user-select: none;
}
.filter-row .fav-only input { margin: 0; }

/* Player controls bar (quality + audio-track pickers) under the video. */
#playerControls {
  display: flex; flex-wrap: wrap; gap: .8rem; align-items: center;
  margin: .4rem 0 .2rem; font-size: .85rem;
}
#playerControls .pc-item { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
#playerControls select {
  background: #1f2025; color: var(--fg); border: 1px solid #2a2c33;
  padding: .25rem .4rem; border-radius: .25rem; font: inherit;
}

/* Global search (live + movies + series) with a results dropdown. */
.gsearch-wrap { position: relative; margin-bottom: .6rem; }
.gsearch-wrap .search-input {
  width: 100%; background: #1f2025; color: var(--fg); border: 1px solid #2a2c33;
  padding: .45rem .6rem; border-radius: .3rem; font: inherit;
}
.search-results {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + .2rem); z-index: 30;
  max-height: 50vh; overflow-y: auto;
  background: #15161a; border: 1px solid #2a2c33; border-radius: .35rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.search-results.open { display: block; }
.search-results .sr-item {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  background: transparent; color: var(--fg); border: 0; border-bottom: 1px solid #1f2025;
  padding: .45rem .6rem; cursor: pointer; text-align: left; font: inherit;
}
.search-results .sr-item:hover { background: #1f2025; }
.search-results .sr-badge {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .03em;
  padding: .08rem .35rem; border-radius: .25rem; flex: none; font-weight: 700;
}
.search-results .sr-live { background: #073; color: #cfe; }
.search-results .sr-movie { background: #234; color: #bcf; }
.search-results .sr-series { background: #324; color: #fce; }
.search-results .sr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-year { color: var(--muted); flex: none; }
.search-results .sr-empty { padding: .5rem .6rem; color: var(--muted); }

/* recently-watched live channel chips */
.recent-chip{
  background:rgba(139,92,246,.16); color:#dcd2fb; border:1px solid rgba(139,92,246,.4);
  border-radius:.35rem; padding:.2rem .5rem; font-size:.8em; cursor:pointer;
  max-width:11rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.recent-chip:hover{ background:rgba(139,92,246,.3); color:#fff; }
