:root {
  --bg: #0b0b14; --bg2: #13131e; --bg3: #1a1a28; --bg4: #212134;
  --gold: #c9a84c; --gold2: #e8c56a; --white: #f0f0f8; --muted: #8a8aa3;
  --red: #e84855; --green: #52d98e;
  --font: 'Outfit', 'Heebo', 'Noto Sans Arabic', system-ui, sans-serif;
  --serif: 'Cormorant Garamond', Georgia, serif;
}
:lang(he) { --font: 'Heebo', 'Outfit', system-ui, sans-serif; }
:lang(ar) { --font: 'Noto Sans Arabic', 'Outfit', system-ui, sans-serif; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--white); font-family: var(--font); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.screen { position: fixed; inset: 0; display: flex; }

/* focus — the remote control needs a clearly visible one */
.focusable { outline: none; transition: background .12s, box-shadow .12s, transform .12s; }
.focusable:focus, .focusable.focus { box-shadow: 0 0 0 3px var(--gold); }

.logo { font-family: var(--serif); font-size: 2.6rem; font-weight: 300; letter-spacing: .02em; direction: ltr; }
.logo span { color: var(--gold); }
.logo.small { font-size: 1.6rem; }

.btn { padding: .7rem 1.4rem; border-radius: 10px; background: var(--bg4); font-weight: 500; }
.btn-gold { background: var(--gold); color: #1a1408; }
.btn-gold:focus { background: var(--gold2); }
.btn-icon { padding: .4rem .8rem; font-size: 1.3rem; }

/* ── activation, expired, settings ─────────────────────────────────────── */
/* margin:auto centres the card but, unlike align-items:center, lets a card taller
   than the screen scroll from its top instead of being cut off */
#activate, #expired, #settings { align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px; }
.act-card { background: var(--bg2); border: 1px solid var(--bg4); border-radius: 18px; padding: 2rem 2.4rem;
  max-width: 820px; width: 100%; display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center;
  margin: auto; }
.act-card h1 { font-weight: 400; font-size: 1.6rem; }
.act-card h3 { font-weight: 500; color: var(--muted); margin-top: .5rem; }
.act-row { display: flex; gap: 2.4rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.act-code { display: flex; flex-direction: column; gap: .9rem; align-items: center; }
.code-boxes { display: flex; gap: .4rem; direction: ltr; }
.code-boxes div { width: 2.4rem; height: 3rem; border-radius: 8px; background: var(--bg3); border: 1px solid var(--bg4);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.code-boxes div.cur { border-color: var(--gold); }
.code-boxes div:nth-child(4) { margin-inline-end: .6rem; }
.numpad { display: grid; grid-template-columns: repeat(3, 3.6rem); gap: .45rem; direction: ltr; }
.numpad button { height: 3rem; border-radius: 10px; background: var(--bg3); font-size: 1.3rem; }
.act-msg { min-height: 1.3em; color: var(--red); }
.act-msg.ok { color: var(--green); }
.act-qr { display: flex; flex-direction: column; align-items: center; gap: .6rem; max-width: 220px; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 200px; height: 200px; }
.qr img, .qr canvas { width: 180px !important; height: 180px !important; }
.lang-row { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.lang-row button { padding: .45rem .9rem; border-radius: 8px; background: var(--bg3); }
.lang-row button.on { background: var(--gold); color: #1a1408; }
#settings .btn { min-width: 260px; }
#settings-info { line-height: 1.6; }

/* ── main ──────────────────────────────────────────────────────────────── */
#main { flex-direction: column; }
.banner { background: #4a1c22; color: #ffd8dc; text-align: center; padding: .55rem 1rem; font-size: .95rem; }
.top { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.4rem; }
.clock { margin-inline-start: auto; font-size: 1.2rem; color: var(--muted); direction: ltr; }
.cols { flex: 1; display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.1fr); gap: 1rem;
  padding: 0 1.4rem 1.2rem; min-height: 0; }

.groups, .channels { overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: .3rem; }
.groups::-webkit-scrollbar, .channels::-webkit-scrollbar { display: none; }
/* Rows are placed by index (app.js renders only those on screen). */
.channels { display: block; }
.ch-pad { --ch-gap: .3; position: relative; }      /* gap between rows, rem */
.ch-pad .ch { position: absolute; left: 0; right: 0; }
.groups button { text-align: start; padding: .65rem .9rem; border-radius: 10px; color: var(--muted); }
.groups button.on { color: var(--white); background: var(--bg3); }
.groups button:focus { color: var(--white); }

.ch { display: flex; align-items: center; gap: .8rem; padding: .5rem .7rem; border-radius: 12px; background: var(--bg2); text-align: start; }
.ch.on { background: var(--bg4); }
.ch-num { width: 2.2rem; color: var(--muted); font-size: .9rem; text-align: center; direction: ltr; }
.ch-logo { width: 54px; height: 36px; border-radius: 6px; background: var(--bg3); object-fit: contain; flex: none; }
.ch-text { flex: 1; min-width: 0; }
.ch-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-now:empty::before { content: '\200b'; }      /* every row one height, with or without EPG */
.ch-now { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-bar { height: 3px; background: var(--bg4); border-radius: 2px; margin-top: .3rem; overflow: hidden; }
.ch-bar i { display: block; height: 100%; background: var(--gold); }
.ch-fav { color: var(--gold); }
.ch-arch { color: var(--gold); font-size: .8rem; white-space: nowrap; flex: none; direction: ltr; opacity: .85; }
.ch-lock { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); padding: 2rem; text-align: center; }

.preview { display: flex; flex-direction: column; gap: .8rem; min-height: 0; }
.preview-video { aspect-ratio: 16 / 9; flex: none; background: #000; border-radius: 14px; overflow: hidden; }  /* a long EPG text scrolls, the picture keeps its size */
.preview-video video { width: 100%; height: 100%; object-fit: contain; }
.preview-info { overflow-y: auto; scrollbar-width: none; padding: 3px;   /* room for the focus ring */ display: flex; flex-direction: column; gap: .2rem; }
.preview-info h2 { font-weight: 500; font-size: 1.3rem; margin-bottom: .3rem; }
.prog { display: flex; gap: .8rem; padding: .35rem 0; border-bottom: 1px solid var(--bg3); font-size: .92rem; }
.prog time { color: var(--muted); direction: ltr; flex: none; width: 3.2rem; }
.prog.now { color: var(--gold2); }
.prog.now time { color: var(--gold); }
.prog p { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
/* the channel title stays while the guide scrolls (recordings above, the rest below) */
.preview-info h2 { position: sticky; top: 0; z-index: 1; background: var(--bg); padding-bottom: .3rem; }
.prog-day { color: var(--gold); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: .7rem 0 .2rem; }
.prog.arch { width: 100%; text-align: start; padding-inline: .4rem; border-radius: 8px; scroll-margin-top: 3rem; }
.prog.arch time { color: var(--gold); }
.prog.arch:focus { background: var(--bg3); }
.prog .arch-hint { color: var(--gold); }
.osd-arch { color: var(--gold); }
.resume { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 6, 10, .72); padding: 16px; }
.resume-card { background: var(--bg2); border: 1px solid var(--bg4); border-radius: 16px; padding: 1.6rem 2rem;
  display: flex; flex-direction: column; gap: .8rem; min-width: min(420px, 100%); text-align: center; }
.resume-card h3 { font-weight: 500; margin-bottom: .4rem; }
.pin-card { align-items: center; }
.pin-card .numpad { margin-top: .4rem; }
#parental-hint { max-width: 520px; text-align: center; }
.ch-lockbtn { font-size: .9em; padding: 0 .3rem; border-radius: 6px; vertical-align: middle; }
.ch-lockbtn:hover { background: var(--bg3); }

/* ── films & series ────────────────────────────────────────────────────── */
.groups .vod-entry { color: var(--gold); border: 1px solid var(--bg4); margin-bottom: .4rem; }
#vod { flex-direction: column; }
.vod-h { font-size: 1.2rem; color: var(--muted); }
.vod-cols { flex: 1; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; padding: 0 1.4rem 1.2rem; min-height: 0; }
#vod-nav .vod-sub { padding-left: 2rem; font-size: .92em; }
#vod-nav .vod-type { font-weight: 500; }
.vod-sec { color: var(--gold); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: .9rem .9rem .2rem; }
.vod-main { display: flex; flex-direction: column; gap: .8rem; min-height: 0; }
.vod-head { display: flex; align-items: baseline; gap: 1rem; min-height: 2.4rem; }
.vod-head h2 { font-weight: 500; font-size: 1.3rem; }
.vod-head { flex-wrap: wrap; row-gap: .6rem; }
.vod-filters { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .5rem; padding: 3px; }
.vf { background: var(--bg3); border: 1px solid var(--bg4); border-radius: 999px; padding: .45rem .95rem; font-size: .88rem; color: var(--muted); }
.vf b { font-weight: 500; color: var(--white); }
.vf.on { border-color: var(--gold); }
.vf.on b { color: var(--gold2); }
.vf:focus { box-shadow: 0 0 0 3px var(--gold); color: var(--white); }
.vod-pick { min-width: min(360px, 100%); text-align: start; }
.vod-pick-list { display: flex; flex-direction: column; gap: .3rem; max-height: 62vh; overflow-y: auto; scrollbar-width: none; padding: 3px; }
.vod-pick-list::-webkit-scrollbar { display: none; }
.vod-pick-list .btn { text-align: start; }
.vod-pick-list .btn.on { color: var(--gold2); }
.vod-q { flex: 1; max-width: 640px; background: var(--bg3); border: 1px solid var(--bg4); border-radius: 10px;
  padding: .6rem .9rem; color: var(--white); font: inherit; }
.vod-q:focus { box-shadow: 0 0 0 3px var(--gold); }
.vod-grid { flex: 1; overflow-y: auto; scrollbar-width: none; display: grid; align-content: start; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: 4px; }   /* room for the focus ring */
.vod-grid::-webkit-scrollbar { display: none; }
.vcard { display: flex; flex-direction: column; gap: .35rem; text-align: start; border-radius: 12px; padding: .4rem; }
.vcard:focus { background: var(--bg3); transform: scale(1.03); }
.vcard-img { flex: none; aspect-ratio: 2 / 3; border-radius: 9px; overflow: hidden; background: var(--bg3); }
.vcard-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard-t { font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vcard-m { font-size: .75rem; color: var(--muted); }

#vodtitle { overflow-y: auto; padding: 2rem 2.4rem; }
.vt { display: flex; gap: 2.4rem; align-items: flex-start; width: 100%; max-width: 1400px; margin: auto; }
.vt-poster { flex: none; width: 300px; aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; background: var(--bg3); }
.vt-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vt-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .9rem; }
.vt-info h1 { font-weight: 500; font-size: 2rem; }
.vt-info h3 { font-weight: 500; color: var(--muted); margin-top: .4rem; }
.vt-meta { color: var(--gold); }
.vt-about { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; max-width: 70ch; }
.vt-about dt { color: var(--muted); }
.vt-about dd { color: #c8c8d6; }
.vt-person { background: none; border: 0; padding: 0 .1rem; color: inherit; font: inherit; cursor: pointer; border-radius: 4px; }
.vt-person:focus, .vt-person:hover { color: var(--gold); outline: 2px solid var(--gold); }
.vod-people { display: flex; flex-wrap: wrap; gap: .4rem; width: 100%; margin-top: .4rem; }
.vod-people:empty { display: none; }
.vt-desc { color: #c8c8d6; line-height: 1.55; max-width: 70ch; }
.vt-vers { display: flex; flex-wrap: wrap; gap: .5rem; }
.vt-vers .btn.on { border-color: var(--gold); color: var(--gold); }
.vt-eps .btn { display: flex; flex-direction: column; gap: .3rem; }
.vt-eps .ch-bar, .vt-play .ch-bar { width: 100%; }
.vt-play { display: flex; flex-direction: column; gap: .5rem; width: fit-content; min-width: 200px; }
.vcard .ch-bar { display: block; width: 100%; margin-top: 0; }
.vt-eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; padding: 3px; }

/* ── fullscreen player ─────────────────────────────────────────────────── */
#player { background: #000; }
#player video { width: 100%; height: 100%; object-fit: contain; }
.osd { position: absolute; inset-inline: 0; bottom: 0; padding: 2rem 2.4rem; display: flex; gap: 1.4rem; align-items: flex-end;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85)); transition: opacity .3s; }
.osd.off { opacity: 0; }
/* the web player's controls: under the info, full width; none inside the APK */
.osd { flex-wrap: wrap; }
.osd-ctl { flex-basis: 100%; display: flex; flex-direction: column; gap: .5rem; }
html.in-apk .osd-ctl { display: none; }
.osd-ctl-row { display: flex; align-items: center; gap: .6rem; direction: ltr; }
.ctl { font-size: 1.35rem; padding: .35rem .6rem; border-radius: 10px; line-height: 1; color: var(--white); }
.ctl:hover, .ctl:focus { background: rgba(255, 255, 255, .15); }
.ctl-time { color: #d0d0dc; font-variant-numeric: tabular-nums; direction: ltr; min-width: 9ch; }
.ctl-spacer { flex: 1; }
.ctl-seek, .ctl-vol { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); cursor: pointer; }
.ctl-seek { width: 100%; }
.ctl-vol { width: 110px; }
.ctl-seek::-webkit-slider-thumb, .ctl-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); }
.ctl-seek::-moz-range-thumb, .ctl-vol::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--gold); }
#player.quiet { cursor: none; }
@media (max-width: 820px) { .ctl-vol { display: none; } .osd { padding: 1rem 16px; } }
.osd-num { font-size: 2.4rem; color: var(--gold); direction: ltr; }
.osd-name { font-size: 1.6rem; }
.osd-epg { color: #d0d0dc; margin-top: .3rem; }
.osd-epg .bar { width: 320px; max-width: 60vw; height: 4px; background: rgba(255, 255, 255, .2); border-radius: 2px; margin: .4rem 0; }
.osd-epg .bar i { display: block; height: 100%; background: var(--gold); }
.osd-tech { color: #9a9ab0; font-size: .85rem; margin-top: .35rem; direction: ltr; text-align: start; }
html.native-video, html.native-video body, html.native-video #player { background: transparent; }
html.native-video #video { visibility: hidden; }
/* The native preview: the video surface shows through the preview box. */
html.native-preview, html.native-preview body, html.native-preview .preview-video { background: transparent; }
html.native-preview #preview { visibility: hidden; }
html.pip #osd, html.pip #spinner, html.pip #player-msg, html.pip #numjump { display: none; }
.set-rows { display: flex; flex-direction: column; gap: .6rem; align-items: center; }
.player-msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 640px; width: calc(100% - 32px);
  background: rgba(19, 19, 30, .95); border: 1px solid var(--bg4); border-radius: 14px; padding: 1.4rem; text-align: center; line-height: 1.5; }
.spinner { position: absolute; top: 50%; left: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.numjump { position: absolute; top: 1.6rem; inset-inline-end: 2rem; font-size: 3rem; color: var(--gold); direction: ltr;
  background: rgba(0, 0, 0, .6); padding: .2rem 1rem; border-radius: 12px; }

.toast { position: fixed; bottom: 2rem; left: 50%; transform: translate(-50%, 2rem); opacity: 0; pointer-events: none;
  background: var(--bg4); padding: .7rem 1.2rem; border-radius: 10px; transition: .25s; z-index: 10; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── TV and large screens: posters readable from the couch — 7 in a row, not 10 ── */
@media (min-width: 1600px) {
  .vod-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1.2rem; }
  .vcard-t { font-size: 1rem; }
  .vcard-m { font-size: .85rem; }
}
html.in-apk .vod-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1.2rem; }

/* ── phones ────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  html, body { overflow: auto; }
  .act-card { padding: 1.4rem 1rem; }
  #main { position: static; min-height: 100%; }
  .top { padding: .7rem 16px; }
  .cols { display: flex; flex-direction: column; padding: 0 16px 16px; }
  .preview { order: -1; }
  .groups { flex-direction: row; overflow-x: auto; flex: none; }
  .groups button { white-space: nowrap; }
  .channels { overflow: visible; }
  .osd { padding: 1rem 16px; }
  #vod { position: static; min-height: 100%; }
  .vod-cols { display: flex; flex-direction: column; padding: 0 16px 16px; }
  #vod-nav { flex-direction: row; overflow-x: auto; flex: none; }
  #vod-nav button { white-space: nowrap; }
  .vod-sec { display: none; }
  .vod-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .vf { white-space: nowrap; }
  .vod-grid { overflow: visible; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
  #vodtitle { padding: 16px; }
  .vt { flex-direction: column; gap: 1rem; }
  .vt-poster { width: min(220px, 60vw); }
  .vt-info h1 { font-size: 1.5rem; }
}
