/* MY WebPlayer styles. Colours come from the theme variables below - see BRANDING.md. */
:root {
  /* Default theme (Midnight). Themes in assets/js/themes.js override these at runtime. */
  --accent: #e11d48;
  --on-accent: #ffffff;
  --bg: #0e1116;
  --bg-2: #151a21;
  --bg-3: #1d232c;
  --line: #2a313b;
  --text: #e8ebef;
  --muted: #8b95a3;
  --scheme: dark;
  /* Worked out from the colours above - no need to edit. */
  --accent-2: color-mix(in srgb, var(--accent) 75%, white);
  --accent-hover: color-mix(in srgb, var(--accent) 82%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--bg));
  --bg-hover: color-mix(in srgb, var(--bg-3) 88%, var(--text));
  --row-line: color-mix(in srgb, var(--line) 55%, var(--bg));
  --header-bg: color-mix(in srgb, var(--bg) 90%, transparent);
  --ok: #22c55e;
  --bad: #ef4444;
  --radius: 10px;
  --header: 60px;
  color-scheme: var(--scheme);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1 { font-size: 1.7rem; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 0; }
p { margin: .4rem 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.note { background: #3b2a12; border: 1px solid #6b4a17; color: #fcd9a0; padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.err { color: #fca5a5; min-height: 1.2em; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  border: 1px solid var(--line); background: var(--bg-3); padding: .6rem 1.05rem;
  border-radius: 999px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .75rem; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--text); flex: none;
}
.icon-btn:hover { background: var(--bg-3); }
input[type=search], input[type=text], input[type=password], input:not([type]), select {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
.btns { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0; }

.fav { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .55rem 1rem; cursor: pointer; font-weight: 600; color: var(--muted); }
.fav[aria-pressed=true] { color: #facc15; border-color: #6b5a12; }
.fav.small { border: 0; padding: 4px; color: var(--muted); opacity: .7; }
.fav.small[aria-pressed=true] { color: #facc15; }

/* ---------- loading ---------- */
.boot, .loader { display: grid; place-items: center; padding: 3rem; }
.boot { height: 100vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-msg { max-width: 560px; margin: 15vh auto; padding: 0 16px; text-align: center; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #f3f4f6; color: #111; padding: .65rem 1.1rem; border-radius: 999px; font-weight: 600; z-index: 100;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1000px 600px at 20% -10%, var(--accent-soft) 0%, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 1.8rem; display: grid; gap: .8rem; box-shadow: 0 20px 60px #0008; }
.login-card label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.login-card label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.login-card .btn { margin-top: .4rem; padding: .75rem; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: .2px; color: var(--text); }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand-logo { height: 32px; width: auto; max-width: 220px; object-fit: contain; display: block; }
.brand.big .brand-icon { width: 52px; height: 52px; border-radius: 14px; }
.brand.big .brand-logo { height: 60px; max-width: 100%; }
.tagline { color: var(--accent-2); font-weight: 600; margin: 0; }
.brand.big { font-size: 1.5rem; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--header); display: flex; align-items: center; gap: 1rem;
  padding: 0 16px; background: var(--header-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: .2rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .45rem .8rem; border-radius: 999px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--bg-3); color: var(--text); }
.search { margin-left: auto; display: flex; align-items: center; gap: .4rem; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 .4rem 0 .8rem; width: min(320px, 32vw); color: var(--muted); }
.search input { border: 0; background: transparent; padding: .5rem .2rem; width: 100%; }

/* ---------- pages ---------- */
.page { max-width: 1500px; margin: 0 auto; padding: 1.4rem 16px 3rem; }
.welcome { margin-bottom: 1.5rem; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-top: 1rem; }
.quick-card { display: flex; align-items: center; gap: .7rem; padding: 1.1rem; border-radius: 14px; background: linear-gradient(135deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line); font-size: 1.05rem; }
.quick-card svg { color: var(--accent-2); }
.quick-card:hover { border-color: var(--accent); }
.row { margin: 1.6rem 0; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .6rem; }
.row-head a { color: var(--accent-2); font-weight: 600; font-size: .9rem; }
.row-scroll { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: .8rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x proximity; }
.row-scroll > * { scroll-snap-align: start; }

/* poster cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem .8rem; }
.card { display: block; min-width: 0; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--bg-3); border: 1px solid var(--line); transition: transform .15s, border-color .15s; }
.card:hover .poster { transform: translateY(-3px); border-color: var(--accent); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.broken { visibility: hidden; }
.poster:has(img.broken)::after { content: "🎬"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2rem; opacity: .35; }
.rating { position: absolute; top: 6px; left: 6px; background: #000b; color: #facc15; font-size: .75rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.card-title { margin-top: .45rem; font-size: .88rem; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #0009; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* channel tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.tile { display: grid; gap: .4rem; padding: .7rem; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); text-align: center; min-width: 0; }
.tile:hover { border-color: var(--accent); }
.tile-logo { aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--bg-3); border-radius: 8px; overflow: hidden; }
.tile-logo img { max-width: 80%; max-height: 80%; object-fit: contain; }
.tile-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-block { margin: 1.5rem 0; }
.result-block h2 { margin-bottom: .7rem; }

/* ---------- category sidebar (shared) ---------- */
.cats { border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg-2); }
.cats ul { list-style: none; margin: 0; padding: .5rem; }
.cats a { display: block; padding: .45rem .7rem; border-radius: 8px; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cats a:hover { background: var(--bg-3); color: var(--text); }
.cats a.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cats-select { display: none; }
.list-head { display: flex; align-items: center; gap: .6rem; padding: .8rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-title { flex: 1; min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-head .filter { width: 200px; }

/* ---------- browse (movies / series) ---------- */
.browse { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: calc(100vh - var(--header)); }
.browse-main { overflow-y: auto; }
.browse-main .grid { padding: 1rem; }

/* ---------- live TV ---------- */
.live { display: grid; grid-template-columns: 220px 320px minmax(0, 1fr); height: calc(100vh - var(--header)); }
.channels { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.channels .list-head .filter { width: 100%; }
.chan-list { overflow-y: auto; flex: 1; }
.chan { display: grid; grid-template-columns: 34px 46px minmax(0, 1fr) auto auto; align-items: center; gap: .55rem; padding: .45rem .7rem; cursor: pointer; border-bottom: 1px solid var(--row-line); }
.chan:hover { background: var(--bg-3); }
.chan.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.chan-num { color: var(--muted); font-size: .8rem; text-align: right; font-variant-numeric: tabular-nums; }
.chan-logo { width: 46px; height: 30px; display: grid; place-items: center; background: var(--bg-3); border-radius: 5px; overflow: hidden; }
.chan-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.chan-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.chan-tag { font-size: .65rem; font-weight: 800; padding: 1px 5px; border-radius: 4px; background: var(--bg-3); color: var(--muted); border: 1px solid var(--line); }
.chan-tag.live { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.stage { overflow-y: auto; min-width: 0; }
.video-wrap { position: relative; background: #000; aspect-ratio: 16 / 9; }
.video-wrap video, .ov-stage video { width: 100%; height: 100%; display: block; background: #000; }
.video-idle { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; pointer-events: none; }
.video-wrap.active .video-idle { display: none; }
.toolbar { display: flex; align-items: center; gap: .4rem; padding: .45rem .8rem; background: var(--bg-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 50px; }
.tb-grow { flex: 1; }
.tb-select { padding: .3rem .5rem; font-size: .85rem; max-width: 170px; }
.badge { font-size: .72rem; font-weight: 700; color: var(--accent-2); background: var(--accent-soft); white-space: nowrap; padding: 3px 8px; border-radius: 999px; }
.badge:empty { display: none; }
.status { font-size: .82rem; color: var(--muted); }
.now { padding: 1rem; }
.now-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.now-title { font-size: 1.2rem; font-weight: 700; flex: 1; min-width: 0; }
.epg { margin-top: .6rem; display: grid; gap: .8rem; }
.prog { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; position: relative; overflow: hidden; }
.prog-head { display: grid; gap: .1rem; }
.prog-when { font-size: .78rem; color: var(--accent-2); font-weight: 700; }
.prog .bar { position: static; margin-top: .5rem; border-radius: 4px; overflow: hidden; background: var(--bg-3); }
.prog-desc { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.guide { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.guide-day { font-size: .9rem; color: var(--muted); margin: 1rem 0 .3rem; text-transform: uppercase; letter-spacing: .5px; }
.guide-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto auto; gap: .7rem; align-items: center; padding: .5rem; border-radius: 8px; }
.guide-row:hover { background: var(--bg-2); }
.guide-row.past { opacity: .75; }
.guide-row.live { background: var(--accent-soft); opacity: 1; }
.guide-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.guide-info p { margin: 0; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.play-error { position: absolute; inset: 0; display: grid; place-content: center; gap: .3rem; padding: 1.2rem; background: #000d; color: #f1f1f1; text-align: center; z-index: 2; overflow: auto; }
.play-error .err-title { max-width: 520px; margin: 0 auto; font-weight: 600; }
.play-error details { color: var(--muted); font-size: .8rem; max-width: 520px; margin: 0 auto; text-align: left; }
.play-error pre { white-space: pre-wrap; word-break: break-all; }
.play-error .btns { justify-content: center; }

/* ---------- detail pages ---------- */
.detail { padding-top: 0; max-width: none; padding-left: 0; padding-right: 0; }
.hero { position: relative; overflow: hidden; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center top; filter: blur(2px) brightness(.35); transform: scale(1.05); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, transparent 60%), linear-gradient(to right, var(--bg) 0%, transparent 70%); }
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; max-width: 1300px; margin: 0 auto; padding: 1.5rem 16px 2rem; }
[data-scheme=light] .hero-bg { filter: blur(3px) brightness(1.15) saturate(.7); opacity: .35; }
.hero-poster { aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--bg-3); box-shadow: 0 20px 50px #000a; }
.hero-poster img { width: 100%; height: 100%; object-fit: cover; }
.hero-text h1 { font-size: 2.1rem; margin-top: .4rem; }
.back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-weight: 600; }
.back:hover { color: var(--text); }
.meta { color: var(--muted); font-weight: 600; }
.plot { max-width: 760px; font-size: 1rem; }
.credits { color: var(--muted); max-width: 760px; font-size: .9rem; }
.credits b { color: var(--text); }
.season-block { max-width: 1300px; margin: 0 auto; padding: 0 16px 3rem; }
.season-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .6rem; margin-bottom: .8rem; border-bottom: 1px solid var(--line); }
.season-tabs button { border: 1px solid var(--line); background: transparent; padding: .45rem .9rem; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--muted); }
.season-tabs button[aria-selected=true] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.episodes { display: grid; gap: .6rem; }
.episode { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1rem; text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; cursor: pointer; }
.episode:hover { border-color: var(--accent); }
.ep-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--bg-3); display: grid; place-items: center; }
.ep-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ep-thumb svg { position: relative; color: #fff; filter: drop-shadow(0 2px 6px #000); opacity: .85; }
.ep-text { display: grid; align-content: start; gap: .15rem; }
.ep-text p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- full-screen player ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: #000; color: #eef0f3; color-scheme: dark; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.ov-top { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; background: #0b0d11; }
.ov-title { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-stage { position: relative; min-height: 0; }
.ov-stage video { object-fit: contain; }
.overlay .toolbar { background: #0b0d11; border: 0; }

/* ---------- settings ---------- */
.settings { max-width: 760px; }
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; margin: 1rem 0; }
.panel h2 { margin-bottom: .7rem; }
.panel dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0 0 1rem; }
.panel dt { color: var(--muted); }
.panel dd { margin: 0; font-weight: 600; }
.radio { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem; border-radius: 8px; cursor: pointer; }
.radio:hover { background: var(--bg-3); }
.radio input { margin-top: .3rem; accent-color: var(--accent); }
.radio span { display: grid; }
.radio small { color: var(--muted); }
.codecs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .3rem; }
.codecs li span { display: inline-block; width: 1.2rem; font-weight: 800; }
.codecs li.ok span { color: var(--ok); }
.codecs li.no { color: var(--muted); }
.codecs li.no span { color: var(--bad); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .live { grid-template-columns: 280px minmax(0, 1fr); }
  .live > .cats { display: none; }
  .live .cats-select { display: block; width: 100%; }
}
@media (max-width: 860px) {
  /* backdrop-filter would trap the fixed bottom tab bar inside the header */
  .top { gap: .5rem; padding: 0 10px; backdrop-filter: none; background: var(--bg); }
  .list-title { flex-basis: 100%; }
  .top .brand .brand-name { display: none; }
  .top .brand-logo { max-width: 120px; height: 28px; }
  .search { width: auto; flex: 1; min-width: 0; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; background: var(--bg); border-top: 1px solid var(--line); padding: .35rem 4px calc(.35rem + env(safe-area-inset-bottom)); z-index: 20; }
  .tabs a { font-size: .8rem; padding: .45rem .55rem; }
  #main { padding-bottom: 64px; }
  .browse { display: block; height: auto; }
  .browse > .cats { display: none; }
  .browse .cats-select { display: block; width: 100%; }
  .browse-main { overflow: visible; }
  .live { display: flex; flex-direction: column; height: auto; }
  .live > .cats { display: none; }
  .stage { order: -1; overflow: visible; position: sticky; top: var(--header); z-index: 5; background: var(--bg); }
  .now { display: none; }
  .channels { border-right: 0; }
  .chan-list { overflow: visible; }
  .list-head .filter, .list-head .sort { flex: 1; width: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .8rem .6rem; }
  .quick { grid-template-columns: 1fr; }
  .hero-inner { grid-template-columns: 120px minmax(0, 1fr); gap: 1rem; }
  .hero-text h1 { font-size: 1.4rem; }
  .episode { grid-template-columns: 120px minmax(0, 1fr); }
  .row-scroll { grid-auto-columns: 120px; }
}
@media (max-width: 520px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-poster { width: 140px; }
}

/* ---------- themes picker, footer ---------- */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .7rem; margin-bottom: .5rem; }
.swatch { background: transparent; border: 2px solid transparent; border-radius: 12px; padding: 4px; cursor: pointer; display: grid; gap: .35rem; text-align: center; color: var(--text); }
.swatch:hover { border-color: var(--line); }
.swatch[aria-checked=true] { border-color: var(--accent); }
.sw-preview { display: grid; gap: 6px; align-content: start; aspect-ratio: 16 / 10; border: 1px solid; border-radius: 8px; overflow: hidden; }
.sw-bar { height: 14px; display: flex; align-items: center; padding: 0 6px; }
.sw-bar i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.sw-line { height: 5px; width: 70%; margin-left: 8px; border-radius: 3px; opacity: .85; }
.sw-line.short { width: 45%; opacity: .6; }
.sw-btn { width: 38px; height: 11px; border-radius: 6px; margin: 2px 0 0 8px; }
.sw-name { font-size: .8rem; font-weight: 600; }
.site-footer { margin: 2.5rem 0 .5rem; text-align: center; color: var(--muted); font-size: .85rem; }
.login-card .login-theme { display: flex; align-items: center; justify-content: center; gap: .5rem; font-size: .85rem; color: var(--muted); font-weight: 400 !important; }
.login-theme select { padding: .3rem .5rem; }