/* Crush OTT web player. Colours and proportions follow the Android TV app.
   1rem is about 14dp on a 960×540dp TV screen, so the layout scales with the window. */

:root {
  --accent: #1E4C9A;
  --accent-hi: #4A70AE;
  --orange: #F58220;
  --bg-top: #2C2F36;
  --bg-bottom: #16171B;
  --home-bg: #111317;
  --surface: #25272D;
  --surface-hi: #33363F;
  --card: #262A31;
  --card-focus: #F2F2F2;
  --text: #FFFFFF;
  --text-2: #D5DBE3;
  --text-dim: #A9AEB8;
  --text-mute: #8E98A6;
  --ink: #15181D;
  --ink-dim: #4B5563;
  --line: rgba(255, 255, 255, .08);
  --radius: .72rem;
  --pad: 2.3rem;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  font-size: clamp(13px, min(1.4583vw, 2.5926vh), 26px);
  height: 100%;
  background: var(--bg-bottom);
}
body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--font); color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
img { display: block; }
img.noimg { visibility: hidden; }
:focus { outline: none; }
.hidden { display: none !important; }
h1, h2, h3, p { margin: 0; }
.ic { display: inline-flex; width: 1.3em; height: 1.3em; flex: none; }
.ic svg { width: 100%; height: 100%; }
::-webkit-scrollbar { width: .45rem; height: .45rem; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 1rem; }
::-webkit-scrollbar-track { background: transparent; }
.scroll-y { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.scroll-x { overflow-x: auto; overscroll-behavior: contain; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

/* ------------------------------------------------------------------ splash */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem; }
.splash-logo { width: 22rem; max-width: 70vw; height: auto; }
.spinner { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: .25rem solid rgba(255,255,255,.15); border-top-color: var(--orange); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; overflow: hidden; display: flex; flex-direction: column; }
.screen.home { background: var(--home-bg); }

.header { display: flex; align-items: center; gap: .9rem; padding: 1.1rem var(--pad) .8rem; min-height: 4.3rem; flex: none; }
.header-title { font-size: 1.45rem; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { color: var(--text-dim); font-size: .95rem; font-weight: 500; margin-left: .6rem; }
.back-btn { display: none; }
body:not(.tv) .back-btn { display: inline-flex; }

.icon-btn {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.08); color: var(--text-2); flex: none; transition: background .12s, color .12s;
}
.icon-btn .ic { width: 1.35rem; height: 1.35rem; }
.icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:focus-visible, body.keys .icon-btn:focus { background: rgba(255,255,255,.2); box-shadow: 0 0 0 .15rem #fff; color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding: .55rem 1.3rem;
  border-radius: .55rem; background: var(--surface-hi); color: var(--text); font-weight: 600; font-size: 1rem;
  transition: background .12s, color .12s, transform .12s; white-space: nowrap;
}
.btn .ic { width: 1.25rem; height: 1.25rem; }
.btn:hover { background: #3d414b; }
.btn.primary { background: var(--accent); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.danger { background: #8E2C2C; }
.btn:focus { background: var(--card-focus); color: var(--ink); transform: scale(1.04); }
.btn.small { min-height: 2.2rem; padding: .35rem .9rem; font-size: .9rem; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.input {
  width: 100%; padding: .85rem 1rem; border-radius: .6rem; border: .12rem solid transparent;
  background: #1C1E23; color: var(--text); font-size: 1.05rem; user-select: text; -webkit-user-select: text;
}
.input:focus { border-color: #fff; background: #23262c; }
.input::placeholder { color: #6f7783; }
.help { color: var(--text-dim); font-size: .92rem; line-height: 1.45; }
.muted { color: var(--text-mute); }
.empty { color: var(--text-dim); padding: 2rem; font-size: 1.05rem; }

/* ------------------------------------------------------------------ top bar and home */
.topbar { display: flex; align-items: center; height: 3.15rem; margin: 1rem var(--pad) 0; gap: .4rem; flex: none; position: relative; z-index: 2; }
.topbar .logo { height: 2.15rem; max-width: 8rem; object-fit: contain; margin-right: 1.1rem; flex: none; }
.nav-row { display: flex; gap: .1rem; flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: .15rem; }
.nav-row::-webkit-scrollbar { display: none; }
.nav-pill {
  padding: .48rem .78rem; border-radius: 1.3rem; color: var(--text-2); font-size: .96rem; white-space: nowrap; font-weight: 500; flex: none;
  transition: background .12s, color .12s;
}
.nav-pill.selected { background: rgba(255,255,255,.15); color: #fff; }
.nav-pill:hover { background: rgba(255,255,255,.1); }
.nav-pill:focus { background: #F2F2F2; color: var(--ink); }
.topbar .spacer { flex: 1; min-width: .5rem; }
.topbar .icon-btn { width: 2.35rem; height: 2.35rem; }
.topbar .icon-btn .ic { width: 1.2rem; height: 1.2rem; }
.topbar .status { color: #9AA4B2; font-size: .86rem; margin-right: .5rem; white-space: nowrap; }
.clock { color: #DDE3EA; font-size: 1.1rem; margin-left: .4rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avatar {
  width: 2.45rem; height: 2.45rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 1.05rem; flex: none;
}
.avatar.kids { background: var(--orange); }
.avatar-btn:focus .avatar, .avatar-btn:hover .avatar { box-shadow: 0 0 0 .15rem #fff; }
.chip-expiry {
  height: 2.15rem; padding: 0 .75rem; flex: none; border-radius: 1.1rem; border: .07rem solid #E0A040; color: #F2C27A;
  font-size: .86rem; display: inline-flex; align-items: center; white-space: nowrap;
}
.chip-expiry:focus { background: rgba(224,160,64,.25); border-color: #fff; }

.home .hero-art {
  position: absolute; top: 0; right: 0; width: 46%; height: 23.6rem; object-fit: cover; opacity: 0; transition: opacity .25s;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 35%), linear-gradient(to bottom, #000 55%, transparent 100%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to right, transparent 0, #000 35%), linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-composite: intersect;
}
.home .hero-art.show { opacity: 1; }
.hero { position: relative; z-index: 1; width: 31.5rem; max-width: 60%; margin: 1.4rem var(--pad) 0; min-height: 12.5rem; flex: none; }
.hero-tag { font-size: .79rem; font-weight: 700; letter-spacing: .12em; color: var(--accent-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-title { font-size: 2rem; font-weight: 700; margin-top: .3rem; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-metaline { display: flex; align-items: center; gap: .7rem; margin-top: .45rem; min-height: 1.4rem; }
.hero-meta { color: var(--text-2); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating { background: #4D5560; border-radius: .3rem; padding: .07rem .36rem; font-size: .86rem; color: #fff; font-weight: 600; flex: none; }
.rating.blue { background: var(--accent); }
.hero-plot { color: #B8C0CB; font-size: .93rem; line-height: 1.45; margin-top: .55rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-progress { display: flex; align-items: center; gap: .7rem; margin-top: .7rem; color: #B8C0CB; font-size: .86rem; }
.hero-hint { color: #7F8A98; font-size: .86rem; margin-top: .7rem; }
.bar { height: .29rem; background: rgba(255,255,255,.18); border-radius: .2rem; overflow: hidden; flex: none; }
.bar > i { display: block; height: 100%; background: var(--accent-hi); border-radius: .2rem; }
.hero-progress .bar { width: 13.6rem; }

.rows { flex: 1; min-height: 0; overflow-y: auto; padding: .6rem 0 1.5rem var(--pad); scrollbar-width: none; position: relative; z-index: 1; }
.rows::-webkit-scrollbar { display: none; }
.row { margin-bottom: 1rem; }
.row-head { display: flex; align-items: baseline; padding-right: var(--pad); margin-bottom: .5rem; }
.row-title { flex: 1; font-size: 1.15rem; font-weight: 700; }
.row-count { color: var(--text-mute); font-size: 1rem; }
.row-track { display: flex; gap: .72rem; padding: .35rem var(--pad) .45rem .2rem; margin-left: -.2rem; scroll-padding: 0 var(--pad); }
.status-line { color: #9AA4B2; padding: 1rem 0; }
.announcement {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(11,13,16,.85); padding: .35rem 0; z-index: 3;
  overflow: hidden; white-space: nowrap; font-size: .93rem; color: rgba(255,255,255,.9);
}
.announcement span { display: inline-block; padding-left: 100%; animation: marquee 22s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* ------------------------------------------------------------------ cards */
.card {
  flex: none; border-radius: var(--radius); background: var(--card); overflow: hidden; position: relative;
  transition: transform .11s ease-out, background .11s; color: #fff;
}
.card:hover { background: #2f343c; }
.card:focus { background: var(--card-focus); color: var(--ink); transform: scale(1.06); z-index: 2; box-shadow: 0 .4rem 1.4rem rgba(0,0,0,.5); }
.card .name { font-size: .93rem; padding: .45rem .6rem .55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: .82rem; color: #9AA4B2; padding: 0 .6rem .55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:focus .sub { color: var(--ink-dim); }
.card .fav-star { position: absolute; top: .4rem; left: .4rem; width: 1.3rem; height: 1.3rem; color: var(--orange); filter: drop-shadow(0 1px 2px #000); }
.card .rating { position: absolute; top: .4rem; right: .4rem; }
.card .watched-tick { position: absolute; top: .4rem; left: .4rem; background: var(--accent); border-radius: 50%; width: 1.4rem; height: 1.4rem; padding: .2rem; color: #fff; }

.card.poster { width: 8.43rem; }
.card.poster .art { width: 100%; aspect-ratio: 2 / 2.85; object-fit: cover; background: #1b1e23 url("../img/placeholder.svg") center / 40% no-repeat; }
.card.poster .bar { position: absolute; left: .5rem; right: .5rem; bottom: 2.45rem; }

.card.wide { width: 15.7rem; }
.card.wide .art { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #1b1e23 url("../img/placeholder.svg") center / 22% no-repeat; }
.card.wide .bar { margin: 0 .6rem .55rem; }

.card.channel { width: 13.6rem; display: flex; flex-direction: column; padding: .7rem; gap: .25rem; }
.card.channel .ch-top { display: flex; align-items: center; gap: .6rem; }
.card.channel .ch-logo { width: 3.3rem; height: 2.3rem; object-fit: contain; flex: none; background: #1b1e23; border-radius: .35rem; padding: .15rem; }
.card.channel:focus .ch-logo { background: #e3e3e3; }
.card.channel .ch-name { font-size: .82rem; color: #9AA4B2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.channel .ch-show { font-size: .98rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .25rem; }
.card.channel .ch-time { font-size: .79rem; color: #9AA4B2; }
.card.channel:focus .ch-name, .card.channel:focus .ch-time { color: var(--ink-dim); }
.card.channel .bar { margin-top: .3rem; }

/* poster grid (Movies, Series, search) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.43rem, 1fr)); gap: 1rem .9rem; padding: .5rem var(--pad) 2rem .6rem; align-content: start; }
.grid .card.poster { width: auto; }

/* ------------------------------------------------------------------ text lists (categories, settings) */
.list { display: flex; flex-direction: column; gap: .18rem; padding: .2rem .4rem; }
.list-item {
  display: flex; align-items: center; gap: .6rem; padding: .62rem .95rem; border-radius: .55rem; color: var(--text-2);
  font-size: 1rem; min-height: 2.65rem; transition: background .1s;
}
.list-item .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .count { color: var(--text-mute); font-size: .86rem; }
.list-item .ic { width: 1.15rem; height: 1.15rem; opacity: .85; }
.list-item:hover { background: rgba(255,255,255,.06); }
.list-item.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.list-item:focus { background: var(--accent); color: #fff; }
.list-item:focus .count { color: rgba(255,255,255,.75); }
.list-item.locked .grow::after { content: " 🔒"; }

/* ------------------------------------------------------------------ Live TV */
.live-body { flex: 1; min-height: 0; display: flex; gap: .8rem; padding: 0 var(--pad) .9rem 1.2rem; }
.live-cats { width: 13.6rem; flex: none; }
.live-channels { flex: 1; min-width: 0; background: var(--surface); border-radius: 1.28rem; padding: .45rem; position: relative; display: flex; flex-direction: column; }
.live-channels .ch-list { flex: 1; min-height: 0; }
.live-side { width: 42%; flex: none; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: .7rem; overflow: hidden; flex: none; }
.preview video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.preview .preview-hint { position: absolute; inset: auto 0 0 0; padding: .4rem .7rem; font-size: .82rem; color: #ddd; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.preview .preview-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; color: #c9ced6; font-size: .93rem; }
.info-ch { font-size: .86rem; color: var(--text-dim); font-weight: 600; letter-spacing: .02em; }
.info-now { font-size: 1.25rem; font-weight: 700; margin-top: .2rem; }
.info-time { color: var(--text-dim); font-size: .86rem; margin-top: .25rem; display: flex; align-items: center; gap: .6rem; }
.info-time .bar { flex: 1; max-width: 12rem; }
.info-desc { color: #B8C0CB; font-size: .9rem; line-height: 1.45; margin-top: .5rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.info-next { color: var(--text-dim); font-size: .86rem; margin-top: .55rem; }
.live-info { flex: 1; min-height: 0; overflow: hidden; }
.side-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.live-hint { color: var(--text-mute); font-size: .82rem; padding: .3rem .5rem 0; }

.ch-row {
  display: flex; width: 100%; align-items: center; gap: .75rem; padding: .4rem .7rem; border-radius: .6rem; min-height: 3.6rem; position: relative;
  transition: background .08s;
}
.ch-row:hover { background: rgba(255,255,255,.06); }
.ch-row:focus { background: var(--card-focus); color: var(--ink); }
.ch-row.playing .ch-name::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--orange); margin-right: .45rem; vertical-align: middle; }
.ch-row .num { width: 2.4rem; text-align: right; color: var(--text-mute); font-size: .9rem; flex: none; font-variant-numeric: tabular-nums; }
.ch-row:focus .num { color: var(--ink-dim); }
.ch-row .logo { width: 3.6rem; height: 2.5rem; object-fit: contain; flex: none; background: rgba(0,0,0,.25); border-radius: .35rem; padding: .15rem; }
.ch-row:focus .logo { background: #dcdcdc; }
.ch-row .txt { flex: 1; min-width: 0; }
.ch-row .ch-name { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-row .ch-now { font-size: .84rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.ch-row:focus .ch-now { color: var(--ink-dim); }
.ch-row .bar { width: 100%; margin-top: .3rem; height: .2rem; }
.ch-row .ic { width: 1.1rem; height: 1.1rem; color: var(--orange); }
.ch-row .catchup-ic { color: var(--text-mute); }

/* ------------------------------------------------------------------ player */
.player { position: fixed; inset: 0; background: #000; z-index: 50; overflow: hidden; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player.fit-cover video { object-fit: cover; }
.player.fit-fill video { object-fit: fill; }
.player.fit-zoom video { object-fit: cover; transform: scale(1.15); }
.player.no-cursor { cursor: none; }
.osd { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s; }
.osd.show { opacity: 1; }
.osd.show .osd-top, .osd.show .osd-bottom { pointer-events: auto; }
.osd-top { position: absolute; top: 0; left: 0; right: 0; padding: 1.4rem var(--pad) 3rem; background: linear-gradient(rgba(0,0,0,.75), transparent); display: flex; align-items: flex-start; gap: 1rem; }
.osd-title { font-size: 1.45rem; font-weight: 700; }
.osd-sub { color: #cfd5dd; font-size: .95rem; margin-top: .25rem; }
.osd-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 3rem var(--pad) 1.4rem; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.seek { display: flex; align-items: center; gap: .9rem; font-size: .9rem; color: #dfe4ea; font-variant-numeric: tabular-nums; }
.seek-track { position: relative; flex: 1; height: .35rem; background: rgba(255,255,255,.25); border-radius: .3rem; cursor: pointer; }
.seek-track .buf { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.3); border-radius: .3rem; }
.seek-track .pos { position: absolute; inset: 0 auto 0 0; background: var(--orange); border-radius: .3rem; }
.seek-track .knob { position: absolute; top: 50%; width: .95rem; height: .95rem; margin: -.475rem 0 0 -.475rem; border-radius: 50%; background: #fff; }
.seek-track:focus { outline: .12rem solid #fff; outline-offset: .35rem; }
.controls { display: flex; align-items: center; gap: .55rem; margin-top: .9rem; }
.controls .spacer { flex: 1; }
.ctl { width: 2.9rem; height: 2.9rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: rgba(255,255,255,.1); flex: none; }
.ctl .ic { width: 1.5rem; height: 1.5rem; }
.ctl.big { width: 3.5rem; height: 3.5rem; }
.ctl.big .ic { width: 2rem; height: 2rem; }
.ctl:hover { background: rgba(255,255,255,.2); }
.ctl:focus { background: #fff; color: var(--ink); }
.ctl-label { font-size: .86rem; color: #cfd5dd; padding: 0 .4rem; white-space: nowrap; }
.volume { width: 6rem; accent-color: var(--orange); }
.spin-center { position: absolute; left: 50%; top: 50%; margin: -1.2rem 0 0 -1.2rem; pointer-events: none; }
.player-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 36rem; width: 86%; text-align: center;
  background: rgba(20,22,26,.92); border-radius: 1rem; padding: 1.6rem; display: flex; flex-direction: column; gap: 1rem; align-items: center;
}
.player-msg p { color: #d6dbe2; line-height: 1.5; }
.player-msg .btns { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }

.banner {
  position: absolute; left: var(--pad); right: var(--pad); bottom: 1.6rem; display: flex; gap: 1.1rem; align-items: center;
  background: rgba(18,20,24,.9); border-radius: 1rem; padding: 1rem 1.3rem; transition: opacity .2s, transform .2s; pointer-events: none;
}
.banner.hide { opacity: 0; transform: translateY(1rem); }
.player.osd-on .banner { bottom: 7.4rem; }
.player.osd-on .banner.vod { bottom: 9.6rem; }
.banner .b-logo { width: 6rem; height: 4rem; object-fit: contain; background: rgba(0,0,0,.3); border-radius: .5rem; padding: .25rem; flex: none; }
.banner .b-num { font-size: 1.9rem; font-weight: 700; color: var(--orange); min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; }
.banner .b-main { flex: 1; min-width: 0; }
.banner .b-ch { font-size: .9rem; color: var(--text-dim); font-weight: 600; }
.banner .b-now { font-size: 1.3rem; font-weight: 700; margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner .b-time { display: flex; align-items: center; gap: .7rem; color: var(--text-dim); font-size: .86rem; margin-top: .35rem; }
.banner .b-time .bar { flex: 1; max-width: 16rem; }
.banner .b-next { color: var(--text-dim); font-size: .86rem; margin-top: .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner .b-clock { font-size: 1.3rem; color: #dfe4ea; align-self: flex-start; }
.num-entry { position: absolute; top: 1.6rem; right: var(--pad); font-size: 3rem; font-weight: 700; background: rgba(0,0,0,.65); padding: .4rem 1.2rem; border-radius: .8rem; color: #fff; font-variant-numeric: tabular-nums; }

.side-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: 30rem; max-width: 92vw; background: rgba(20,22,26,.96);
  display: flex; flex-direction: column; padding: 1.2rem .8rem; transform: translateX(-100%); transition: transform .18s ease-out;
}
.side-panel.open { transform: none; }
.side-panel .sp-title { font-size: 1.15rem; font-weight: 700; padding: 0 .6rem .7rem; }
.side-panel .ch-list { flex: 1; min-height: 0; }

.upnext {
  position: absolute; right: var(--pad); bottom: 6.5rem; width: 22rem; background: rgba(20,22,26,.95); border-radius: 1rem; padding: 1rem;
  display: flex; flex-direction: column; gap: .7rem;
}
.upnext .un-label { color: var(--orange); font-weight: 700; font-size: .82rem; letter-spacing: .1em; }
.upnext .un-title { font-weight: 700; }
.upnext .un-btns { display: flex; gap: .5rem; }

/* multi-view */
.multiview { position: fixed; inset: 0; background: #000; z-index: 50; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: .2rem; }
.mv-cell { position: relative; background: #0b0c0e; display: flex; align-items: center; justify-content: center; border: .15rem solid transparent; overflow: hidden; }
.mv-cell video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mv-cell:focus { border-color: #fff; }
.mv-cell.audio { border-color: var(--orange); }
.mv-cell .mv-label { position: absolute; left: .6rem; bottom: .5rem; font-size: .86rem; background: rgba(0,0,0,.6); padding: .2rem .5rem; border-radius: .35rem; }
.mv-cell .mv-add { color: var(--text-dim); display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.mv-cell .mv-add .ic { width: 2.2rem; height: 2.2rem; }

/* ------------------------------------------------------------------ guide */
.guide-top { display: flex; gap: 1.2rem; padding: 0 var(--pad) .7rem 1.2rem; flex: none; height: 13.5rem; }
.guide-top .preview { width: 24rem; height: 100%; aspect-ratio: auto; }
.guide-top .gi { flex: 1; min-width: 0; padding-top: .2rem; }
.guide-wrap { flex: 1; min-height: 0; position: relative; display: flex; padding: 0 0 0 1.2rem; }
.guide-cats { width: 13rem; flex: none; position: absolute; left: 0; top: 0; bottom: 0; z-index: 6; background: rgba(20,22,26,.97); transform: translateX(-100%); transition: transform .16s; padding: .4rem; }
.guide-cats.open { transform: none; }
.guide-grid { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.tl-head { display: flex; height: 2.1rem; flex: none; }
.tl-head .tl-day { width: 15rem; flex: none; padding-left: .6rem; color: var(--text-dim); font-size: .86rem; line-height: 2.1rem; font-weight: 600; }
.tl-track { flex: 1; position: relative; overflow: hidden; }
.tl-head .tl-mark { position: absolute; top: 0; height: 100%; font-size: .86rem; color: var(--text-dim); border-left: .07rem solid var(--line); padding-left: .4rem; line-height: 2.1rem; }
.epg-rows { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; position: relative; }
.epg-rows::-webkit-scrollbar { display: none; }
.epg-row { display: flex; height: 3.6rem; border-bottom: .07rem solid rgba(0,0,0,.35); }
.epg-ch { width: 15rem; flex: none; display: flex; align-items: center; gap: .55rem; padding: 0 .6rem; background: var(--surface); border-radius: .45rem 0 0 .45rem; margin: .12rem 0; }
.epg-ch .num { color: var(--text-mute); font-size: .82rem; width: 1.9rem; text-align: right; flex: none; }
.epg-ch .logo { width: 2.8rem; height: 2rem; object-fit: contain; flex: none; }
.epg-ch .nm { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.epg-ch.playing .nm { color: var(--orange); }
.epg-line { flex: 1; position: relative; overflow: hidden; margin: .12rem 0; }
.epg-prog {
  position: absolute; top: 0; bottom: 0; background: #2a2d34; border-radius: .35rem; padding: .35rem .55rem; overflow: hidden;
  border-right: .14rem solid var(--home-bg); white-space: nowrap; display: flex; flex-direction: column; justify-content: center;
}
.epg-prog .t { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.epg-prog .s { font-size: .76rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.epg-prog.now { background: #353a44; }
.epg-prog.past { background: #23262c; color: #9aa1ab; }
.epg-prog.past.archive .t::before { content: "↺ "; color: var(--accent-hi); }
.epg-prog.reminder .t::after { content: " 🔔"; }
.epg-prog:hover { background: #3c414b; }
.epg-prog:focus { background: var(--card-focus); color: var(--ink); z-index: 2; }
.epg-prog:focus .s { color: var(--ink-dim); }
.epg-prog.empty-prog { color: var(--text-mute); }
.now-line { position: absolute; top: 2.1rem; bottom: 1.9rem; width: .14rem; background: var(--orange); z-index: 3; pointer-events: none; }
.guide-hint { color: var(--text-mute); font-size: .8rem; padding: .35rem 0 .45rem; flex: none; }

/* ------------------------------------------------------------------ browse */
.browse-body { flex: 1; min-height: 0; display: flex; gap: .4rem; padding-left: 1.2rem; }
.browse-cats { width: 15.7rem; flex: none; }
.browse-main { flex: 1; min-width: 0; overflow-y: auto; scrollbar-width: thin; }
.browse-main .sec-title { padding: .2rem var(--pad) .5rem .6rem; font-size: 1.05rem; color: var(--text-dim); }

/* ------------------------------------------------------------------ details */
.detail { background: var(--home-bg); }
.detail .backdrop { position: absolute; top: 0; right: 0; width: 70%; height: 80%; object-fit: cover; opacity: .55;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 45%), linear-gradient(to bottom, #000 50%, transparent);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to right, transparent, #000 45%), linear-gradient(to bottom, #000 50%, transparent); mask-composite: intersect; }
.detail-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--pad) 2rem; display: flex; gap: 2rem; scrollbar-width: none; }
.detail-body::-webkit-scrollbar { display: none; }
.detail .poster { width: 13.5rem; flex: none; border-radius: .8rem; aspect-ratio: 2 / 3; object-fit: cover; background: #1b1e23; align-self: flex-start; box-shadow: 0 .6rem 2rem rgba(0,0,0,.5); }
.detail .d-main { flex: 1; min-width: 0; max-width: 46rem; }
.d-title { font-size: 2.15rem; font-weight: 700; line-height: 1.15; }
.d-meta { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; color: var(--text-2); margin-top: .6rem; font-size: 1rem; }
.d-genre { color: var(--text-dim); margin-top: .35rem; font-size: .93rem; }
.d-plot { color: #C3CAD3; line-height: 1.55; margin-top: .9rem; font-size: 1rem; }
.d-people { margin-top: .9rem; font-size: .9rem; color: var(--text-dim); line-height: 1.5; }
.d-people b { color: var(--text-2); font-weight: 600; }
.d-buttons { display: flex; gap: .6rem; margin-top: 1.3rem; flex-wrap: wrap; }
.d-progress { display: flex; align-items: center; gap: .7rem; margin-top: 1rem; color: var(--text-dim); font-size: .86rem; }
.d-progress .bar { width: 14rem; }

.seasons { display: flex; gap: .4rem; margin-top: 1.6rem; flex-wrap: nowrap; padding: .3rem .2rem; }
.season-tab { padding: .45rem 1rem; border-radius: 1.3rem; background: rgba(255,255,255,.08); white-space: nowrap; font-size: .95rem; color: var(--text-2); }
.season-tab.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.season-tab:focus { background: #F2F2F2; color: var(--ink); }
.episodes { display: flex; flex-direction: column; gap: .6rem; margin-top: .9rem; }
.ep { display: flex; width: 100%; gap: 1rem; padding: .6rem; border-radius: .8rem; background: var(--card); align-items: flex-start; transition: background .1s; }
.ep:hover { background: #2f343c; }
.ep:focus { background: var(--card-focus); color: var(--ink); }
.ep .still { width: 12.9rem; aspect-ratio: 16 / 9; border-radius: .5rem; object-fit: cover; flex: none; background: #1b1e23; }
.ep .ep-main { flex: 1; min-width: 0; }
.ep .ep-title { font-weight: 700; font-size: 1rem; }
.ep .ep-meta { color: var(--text-dim); font-size: .84rem; margin-top: .2rem; }
.ep:focus .ep-meta, .ep:focus .ep-plot { color: var(--ink-dim); }
.ep .ep-plot { color: #B8C0CB; font-size: .88rem; line-height: 1.45; margin-top: .35rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ep .bar { margin-top: .5rem; width: 10rem; }
.ep .tick { color: var(--accent-hi); }
.ep:focus .tick { color: var(--accent); }

/* ------------------------------------------------------------------ catch-up, search, settings */
.three-col { flex: 1; min-height: 0; display: flex; gap: .7rem; padding: 0 var(--pad) 1rem 1.2rem; }
.three-col > .col { min-width: 0; }
.col-a { width: 16rem; flex: none; }
.col-b { width: 11rem; flex: none; }
.col-c { flex: 1; background: var(--surface); border-radius: 1.2rem; padding: .45rem; }
.prog-row { display: flex; width: 100%; gap: .9rem; align-items: center; padding: .55rem .8rem; border-radius: .6rem; min-height: 3.3rem; }
.prog-row:hover { background: rgba(255,255,255,.06); }
.prog-row:focus { background: var(--card-focus); color: var(--ink); }
.prog-row .tm { width: 4.8rem; flex: none; color: var(--text-dim); font-size: .9rem; font-variant-numeric: tabular-nums; }
.prog-row:focus .tm, .prog-row:focus .ds { color: var(--ink-dim); }
.prog-row .tt { font-weight: 600; }
.prog-row .ds { font-size: .82rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog-row .grow { flex: 1; min-width: 0; }

.search-bar { display: flex; gap: .6rem; align-items: center; padding: 0 var(--pad) .8rem 1.4rem; flex: none; }
.search-bar .input { flex: 1; max-width: 40rem; }
.search-tabs { display: flex; gap: .3rem; padding: 0 var(--pad) .5rem 1.2rem; flex: none; }
.search-results { flex: 1; min-height: 0; overflow-y: auto; padding-left: 1.2rem; }
.search-results h3 { font-size: 1.05rem; padding: .7rem .6rem .3rem; color: var(--text-dim); font-weight: 600; }
.search-results .row-track { padding-left: .6rem; }

.settings-body { flex: 1; min-height: 0; display: flex; gap: 1.2rem; padding: 0 var(--pad) 1rem 1.2rem; }
.settings-nav { width: 16rem; flex: none; }
.settings-pane { flex: 1; min-width: 0; background: var(--surface); border-radius: 1.2rem; padding: 1.2rem 1.3rem; overflow-y: auto; }
.settings-pane h2 { font-size: 1.25rem; margin-bottom: .9rem; }
.set-row {
  display: flex; align-items: center; gap: 1rem; width: 100%; padding: .8rem 1rem; border-radius: .6rem; min-height: 3.3rem;
  background: rgba(255,255,255,.04); margin-bottom: .4rem;
}
.set-row:hover { background: rgba(255,255,255,.08); }
.set-row:focus { background: var(--card-focus); color: var(--ink); }
.set-row .sr-main { flex: 1; min-width: 0; }
.set-row .sr-label { font-weight: 600; }
.set-row .sr-sub { color: var(--text-dim); font-size: .86rem; margin-top: .15rem; }
.set-row:focus .sr-sub, .set-row:focus .sr-val { color: var(--ink-dim); }
.set-row .sr-val { color: var(--text-dim); font-size: .93rem; white-space: nowrap; }
.set-row.lockedset .sr-val::after { content: " · set by provider"; }
.account-box { background: rgba(0,0,0,.2); border-radius: .8rem; padding: 1rem 1.2rem; line-height: 1.75; margin-bottom: 1rem; color: var(--text-2); }

/* ------------------------------------------------------------------ login */
.login { align-items: center; justify-content: center; overflow-y: auto; }
.login-card { width: 32rem; max-width: 92vw; display: flex; flex-direction: column; gap: .9rem; padding: 2rem 0; }
.login-card .logo { height: 4.3rem; object-fit: contain; align-self: center; margin-bottom: .6rem; }
.login-card .sub { color: var(--text-dim); text-align: center; margin-bottom: .4rem; }
.seg { display: flex; background: #1C1E23; border-radius: .7rem; padding: .25rem; gap: .25rem; }
.seg button { flex: 1; padding: .6rem; border-radius: .5rem; text-align: center; color: var(--text-dim); font-weight: 600; }
.seg button.on { background: var(--surface-hi); color: #fff; }
.seg button:focus { background: #F2F2F2; color: var(--ink); }
.login-card .btn.primary { margin-top: .4rem; min-height: 3.1rem; }
.login-error { color: #FF9C8A; text-align: center; min-height: 1.3rem; }
.maint { text-align: center; max-width: 38rem; display: flex; flex-direction: column; gap: 1.2rem; align-items: center; padding: 2rem; }
.maint h1 { font-size: 1.8rem; }
.maint p { color: var(--text-2); line-height: 1.5; }

/* ------------------------------------------------------------------ dialogs */
#layers > * { z-index: 100; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.dialog {
  background: #23262C; border-radius: 1.1rem; padding: 1.5rem; width: 30rem; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 1rem 3rem rgba(0,0,0,.6);
}
.dialog-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .9rem; }
.dialog-body { color: var(--text-2); line-height: 1.5; overflow-y: auto; }
.dialog-body p + p { margin-top: .6rem; }
.dialog-buttons { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.3rem; flex-wrap: wrap; }
.dialog form .input { margin-top: .6rem; }
.dialog.menu { padding: 1.2rem .8rem; width: 26rem; }
.dialog.menu .dialog-title { padding: 0 .7rem; }
.menu-list { overflow-y: auto; display: flex; flex-direction: column; gap: .15rem; scrollbar-width: thin; }
.menu-item { display: flex; width: 100%; align-items: center; gap: .8rem; padding: .75rem .9rem; border-radius: .55rem; color: var(--text-2); min-height: 3rem; }
.menu-item:hover { background: rgba(255,255,255,.07); }
.menu-item:focus { background: var(--card-focus); color: var(--ink); }
.menu-item.checked { color: #fff; font-weight: 600; }
.menu-item.checked:focus { color: var(--ink); }
.menu-item.disabled { opacity: .45; }
.mi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mi-sub { font-size: .82rem; color: var(--text-dim); font-weight: 400; margin-top: .1rem; }
.menu-item:focus .mi-sub { color: var(--ink-dim); }
.mi-icon, .mi-check { width: 1.3rem; height: 1.3rem; display: inline-flex; flex: none; }
.mi-icon svg, .mi-check svg { width: 100%; height: 100%; }

.pin { width: 21rem; align-items: center; }
.pin-dots { display: flex; gap: .9rem; margin: .3rem 0 1.2rem; }
.pin-dots span { width: 1rem; height: 1rem; border-radius: 50%; border: .14rem solid #9aa1ab; }
.pin-dots span.on { background: #fff; border-color: #fff; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 4.3rem); gap: .55rem; }
.pin-key { height: 3.6rem; border-radius: .7rem; background: var(--surface-hi); font-size: 1.35rem; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.pin-key.primary { background: var(--accent); font-size: 1rem; }
.pin-key .ic, .pin-key span svg { width: 1.4rem; height: 1.4rem; }
.pin-key:focus { background: #fff; color: var(--ink); }

.renew { display: flex; flex-direction: column; gap: .8rem; align-items: center; text-align: center; }
.qr { width: 12rem; height: 12rem; background: #fff; border-radius: .6rem; padding: .3rem; }
.qr svg { width: 100%; height: 100%; display: block; }
.renew-link { font-size: .82rem; color: var(--text-dim); word-break: break-all; }

#toast {
  position: fixed; left: 50%; bottom: 3.2rem; transform: translate(-50%, 1rem); background: #f2f2f2; color: var(--ink);
  padding: .7rem 1.3rem; border-radius: 1.6rem; font-size: .95rem; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 300; max-width: 90vw; text-align: center; box-shadow: 0 .4rem 1.4rem rgba(0,0,0,.45);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.trailer-frame { width: min(90vw, 160vh); aspect-ratio: 16 / 9; border: 0; border-radius: .8rem; background: #000; }

/* keyboard users see focus rings on plain links too */
body.keys a:focus { outline: .12rem solid #fff; outline-offset: .2rem; }

/* ------------------------------------------------------------------ phones and small windows */
@media (max-width: 760px), (max-height: 430px) and (max-width: 950px) {
  html { font-size: 14px; }
  :root { --pad: 1rem; }
  .topbar { margin-top: .6rem; height: auto; flex-wrap: wrap; row-gap: .5rem; }
  .topbar .logo { height: 1.8rem; margin-right: auto; }
  .nav-row { order: 5; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav-row::-webkit-scrollbar { display: none; }
  .clock, .topbar .status { display: none; }
  .home .hero-art { width: 100%; height: 15rem; opacity: 0; }
  .home .hero-art.show { opacity: .35; }
  .hero { width: auto; max-width: none; min-height: 0; margin-top: 1rem; }
  .hero-title { font-size: 1.5rem; }
  .hero-hint { display: none; }
  .card.poster { width: 7.4rem; }
  .card.wide { width: 13rem; }
  .card.channel { width: 12rem; }
  .card:focus { transform: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(6.8rem, 1fr)); padding: .4rem 1rem 2rem; gap: .8rem .6rem; }

  .header { padding: .7rem 1rem .5rem; min-height: 3.4rem; }
  .header-title { font-size: 1.2rem; }

  .live-body, .browse-body, .three-col, .settings-body { flex-direction: column; padding: 0 0 .6rem; gap: .5rem; }
  .live-side { width: auto; order: -1; padding: 0 1rem; gap: .4rem; }
  .live-info .info-desc, .live-info .info-next, .live-hint { display: none; }
  /* Fixed height: the channel list mustn't move under a finger when the info changes. */
  .live-info { flex: none; height: 4.4rem; }
  .live-info .info-now { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.1rem; }
  .live-cats, .browse-cats, .col-a, .col-b, .settings-nav, .guide-cats.inline { width: auto; flex: none; }
  .live-cats .list, .browse-cats .list, .col-a .list, .col-b .list, .settings-nav .list { flex-direction: row; overflow-x: auto; scrollbar-width: none; padding: .2rem 1rem; }
  .live-cats .list::-webkit-scrollbar, .browse-cats .list::-webkit-scrollbar { display: none; }
  .live-cats .list-item, .browse-cats .list-item, .col-a .list-item, .col-b .list-item, .settings-nav .list-item {
    flex: none; min-height: 2.3rem; padding: .4rem .9rem; border-radius: 1.2rem; background: rgba(255,255,255,.07);
  }
  .list-item .count { display: none; }
  .live-channels, .col-c { margin: 0 .6rem; border-radius: .9rem; flex: 1; min-height: 0; }
  .settings-pane { margin: 0 .6rem; border-radius: .9rem; padding: 1rem; }
  .side-buttons .btn { flex: 1; padding: .4rem .6rem; min-height: 2.4rem; }

  .guide-top { height: auto; flex-direction: column; padding: 0 1rem .5rem; gap: .5rem; }
  .guide-top .preview { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .guide-top .gi .info-desc { -webkit-line-clamp: 2; }
  .guide-wrap { padding: 0; }
  .tl-head .tl-day { width: 6rem; padding-left: .3rem; font-size: .76rem; }
  .epg-ch { width: 6rem; padding: 0 .3rem; }
  .epg-ch .num, .epg-ch .nm { display: none; }
  .epg-ch .logo { width: 100%; }
  .guide-hint { display: none; }

  .detail-body { flex-direction: column; gap: 1rem; padding-top: .5rem; }
  .detail .poster { width: 9rem; }
  .detail .backdrop { width: 100%; height: 45%; }
  .d-title { font-size: 1.6rem; }
  .ep { flex-direction: column; }
  .ep .still { width: 100%; }

  .banner { left: .6rem; right: .6rem; bottom: .6rem; padding: .7rem; gap: .7rem; }
  .banner .b-logo { width: 3.6rem; height: 2.6rem; }
  .banner .b-clock, .banner .b-next { display: none; }
  .osd-bottom { padding: 2rem 1rem 1rem; }
  .controls { flex-wrap: wrap; gap: .35rem; }
  .ctl { width: 2.5rem; height: 2.5rem; }
  .volume { display: none; }
  .upnext { left: 1rem; right: 1rem; width: auto; bottom: 7rem; }
  .multiview { grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); }
  .search-bar { padding: 0 1rem .6rem; }
  .search-tabs { padding: 0 1rem .4rem; overflow-x: auto; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .live-side .live-info { display: none; }
}

@media (max-width: 1100px) and (min-width: 761px) {
  .topbar .clock { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
