/* MyTv — styles. Designed for 10-foot TV use first, scales down to phones. */
:root { --sub-size: 1.6em; --sub-color: #fff; --sub-bg: rgba(0,0,0,.55); --r: 14px; --gap: 14px; --sidebar: 260px; }
/* Twilight, from the earlier "Sophisticated Harmony" palette:
   Dark Blue #1A1F36 · Light Beige #EFDAB9 · Soft Pink #F9AFAF · Cool Blue #3D5B9B */
body { --tile1: linear-gradient(160deg, #F9AFAF 0%, #9b88ad 50%, #3D5B9B 100%); --tile2: linear-gradient(160deg, #3D5B9B, #1A1F36); --tile3: linear-gradient(160deg, #EFDAB9 0%, #b59a9e 45%, #1A1F36 100%); }
/* "Sculpted Sage" palette (from the user's reference): sage #9BADA5 · teal #728D84 · slate #24302E · card #DEE3D9 · terracotta #C08C5C · clay #AE794C · brown #815535 · sand #C7BCA5 */
body[data-theme="gallery"]    { --bg: #7E928B; --bg2: #DEE3D9; --panel: #EEF1EC; --panel2: #DCE3DC; --line: #B4C2BB; --text: #1A2422; --muted: #33423E; --accent: #8A5A35; --accent2: #24302E; --on-accent: #FFFFFF;
  --btn-grad: linear-gradient(135deg, #C08C5C, #AE794C); --tile1: linear-gradient(160deg, #C08C5C 0%, #AE794C 55%, #815535 100%); --tile2: linear-gradient(160deg, #DEE3D9 0%, #9BADA5 45%, #3D4B48 100%); --tile3: linear-gradient(160deg, #EFE6D6 0%, #C7BCA5 45%, #6E5A48 100%);
  --elev: 0 10px 26px rgba(26, 36, 34, .22); }
body[data-theme="slate"]      { --bg: #1E2826; --bg2: #24302E; --panel: #2D3B38; --panel2: #374744; --line: #44554F; --text: #E8EDE6; --muted: #A0B1AA; --accent: #D49A66; --accent2: #8FAAA0; --on-accent: #1E2826;
  --btn-grad: linear-gradient(135deg, #D49A66, #C7BCA5); --tile1: linear-gradient(160deg, #C08C5C 0%, #AE794C 55%, #6E472C 100%); --tile2: linear-gradient(160deg, #8FAAA0 0%, #5E7A72 55%, #2D3B38 100%); --tile3: linear-gradient(160deg, #C7BCA5 0%, #7F8A80 55%, #2D3B38 100%); }
body[data-theme="sand"]       { --bg: #EAE2D3; --bg2: #F2ECE1; --panel: #FAF6EF; --panel2: #EFE6D6; --line: #DDD0BB; --text: #2A2622; --muted: #6E6458; --accent: #4F6B63; --accent2: #C08C5C; --on-accent: #FFFFFF;
  --btn-grad: linear-gradient(135deg, #728D84, #4F6B63); --tile1: linear-gradient(160deg, #728D84 0%, #4F6B63 55%, #24302E 100%); --tile2: linear-gradient(160deg, #C08C5C 0%, #AE794C 55%, #815535 100%); --tile3: linear-gradient(160deg, #C7BCA5 0%, #9BADA5 50%, #4F6B63 100%);
  --elev: 0 8px 22px rgba(80, 64, 44, .10), 0 1px 0 rgba(255, 255, 255, .8) inset; }
body[data-theme="twilight"] { --bg: #3a3046; --bg2: #43384f; --panel: #4d4159; --panel2: #594c66; --line: #6a5b76; --text: #F7EEDF; --muted: #c4b3c2; --accent: #F9AFAF; --accent2: #EFDAB9; --on-accent: #1A1F36; --btn-grad: linear-gradient(135deg, #F9AFAF, #EFDAB9); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 "Sora", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: start; padding: 0; }
input, select { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.muted { color: var(--muted); } .small { font-size: .82rem; } .pad { padding: 16px; } .warn { color: var(--accent2); }
.hidden, [hidden] { display: none !important; }

/* Focus ring — the most important thing on a TV.
   Drawn with box-shadow (follows rounded corners on every WebView, never clipped by the outline box):
   standalone controls get an outer double ring (a gap in the page colour, then the accent),
   rows inside scrolling lists get an inset ring so they never spill onto neighbours or get cut off. */
:focus { outline: none; }
.focusable:focus, button:focus, a:focus { box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent); }
.phone-link:focus, .cat:focus, .ch:focus, .menu-item:focus, .pick:focus, .set-row:focus, .prog:focus, .chl-item:focus, .ep:focus, .pl-main:focus, .sr-row .ch:focus {
  box-shadow: inset 0 0 0 3px var(--accent); }
.cat.active:focus, .ch.active:focus { box-shadow: inset 4px 0 0 var(--accent), inset 0 0 0 3px var(--accent); }
[dir="rtl"] .cat.active:focus, [dir="rtl"] .ch.active:focus { box-shadow: inset -4px 0 0 var(--accent), inset 0 0 0 3px var(--accent); }
/* filled (accent-coloured) controls: ring in the text colour so it stays visible */
.btn.primary:focus, .tab.active:focus, .menu-item.checked:focus { box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--text); }
.menu-item.checked:focus { box-shadow: inset 0 0 0 3px var(--text); }

#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
body.playing #app { visibility: hidden; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg2); flex: none; }
.tb-title { font-size: 1.35rem; margin: 0; flex: 1; font-weight: 700; letter-spacing: .01em; }
.tb-actions { display: flex; gap: 8px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.clock.big { font-size: 2rem; color: var(--text); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; background: var(--panel); border: 1px solid var(--line); flex: none; }
.icon-btn:hover, .icon-btn:focus { background: var(--panel2); }
.back-btn { font-size: 1.9rem; line-height: 1; }
[dir="rtl"] .back-btn { transform: scaleX(-1); }

.btn { padding: 11px 20px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--btn-grad, linear-gradient(135deg, var(--accent), var(--accent2))); color: var(--on-accent); border-color: transparent; }
.btn.danger { background: #b4232c; color: #fff; border-color: transparent; }
.btn.big { padding: 16px 28px; font-size: 1.1rem; }
.btn.small { padding: 6px 12px; font-size: .85rem; }


/* ---------- loading / toast ---------- */
.loading-overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: color-mix(in srgb, var(--bg) 86%, transparent); display: grid; place-content: center; justify-items: center; gap: 16px; z-index: 100; }
.spinner, .p-spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 30px); background: var(--panel2); border: 1px solid var(--line); padding: 12px 22px; border-radius: 999px; opacity: 0; transition: .25s; z-index: 300; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- modal ---------- */
.modal-back { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 200; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(460px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal.wide { width: min(720px, 100%); }
.modal-title { margin: 0 0 14px; font-size: 1.2rem; }
.modal-body { overflow: auto; flex: 1; min-height: 0; padding: 6px; margin: -6px; } /* room so focus rings aren't clipped */
.modal-body > p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; }
.menu-item:hover, .menu-item:focus { background: var(--panel2); }
.menu-item.checked { color: var(--accent); font-weight: 600; }
.mi-swatch { width: 34px; height: 22px; border-radius: 6px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.mi-icon { width: 22px; text-align: center; opacity: .85; } .mi-check { margin-inline-start: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; } .field > span { font-size: .85rem; color: var(--muted); }
.tabs, .season-tabs, .day-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 9px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: .92rem; }
.tab.active { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow: auto; margin-top: 10px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; }
.pick:hover, .pick:focus { background: var(--panel2); }
.chk { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.pick.on .chk { background: var(--accent); border-color: var(--accent); }
.pick.on .chk::after { content: "✓"; color: var(--on-accent); font-size: .8rem; font-weight: 700; }
.row-gap { display: flex; gap: 8px; }
.yt { aspect-ratio: 16/9; } .yt iframe { width: 100%; height: 100%; border: 0; border-radius: 10px; }

/* ---------- images ---------- */
.img-wrap { position: relative; overflow: hidden; background: var(--panel2); display: grid; place-items: center; flex: none; }
.img-wrap img { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.img-ph { font-weight: 700; color: var(--muted); font-size: .9rem; }
.ch-logo { width: 44px; height: 44px; border-radius: 10px; } .ch-logo img { object-fit: contain; padding: 3px; }
.ch-logo.sm { width: 30px; height: 30px; border-radius: 7px; }

/* ---------- playlists ---------- */
.pl-wrap { flex: 1; overflow: auto; padding: 28px; display: flex; flex-direction: column; gap: 20px; align-items: center; }
.pl-list { width: min(760px, 100%); display: flex; flex-direction: column; gap: 10px; }
.pl-card { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; }
.pl-card.active { border-color: var(--accent); }
.pl-main { flex: 1; display: flex; gap: 14px; align-items: center; padding: 8px; border-radius: 10px; min-width: 0; }
.pl-type { width: 52px; height: 52px; border-radius: 12px; background: var(--panel2); display: grid; place-items: center; font-weight: 700; color: var(--accent); flex: none; }
.pl-info { min-width: 0; } .pl-name { font-weight: 700; font-size: 1.1rem; }
.pl-info .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-hero { text-align: center; padding: 30px 10px; display: grid; justify-items: center; gap: 12px; color: var(--muted); max-width: 460px; margin: 0 auto; }
.disclaimer { color: var(--muted); font-size: .82rem; max-width: 560px; text-align: center; }
.logo-mark { width: 46px; height: 46px; border-radius: 13px; flex: none; display: block; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.logo-mark.big { width: 96px; height: 96px; border-radius: 26px; }

/* ---------- home ---------- */
.screen-home { background: radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%), radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--accent2) 14%, transparent), transparent 60%), var(--bg); }
.home-head { display: flex; justify-content: space-between; align-items: center; padding: 28px 44px 10px; }
.brand { display: flex; gap: 14px; align-items: center; } .brand-name { font-weight: 700; font-size: 1.3rem; }
.home-time { text-align: end; }
.home-main { flex: 1; overflow: auto; padding: 18px 44px 32px; display: flex; flex-direction: column; gap: 26px; }
.home-main > * { flex: none; }
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px; min-height: 230px; }
.tile { border-radius: 22px; padding: 26px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; position: relative; overflow: hidden; border: 1px solid var(--line); background: var(--panel); transition: transform .15s; }
.tile::before { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; opacity: .9; z-index: 0; }
.tile > * { position: relative; z-index: 1; }
.t-live::before { background: var(--tile1, linear-gradient(140deg, color-mix(in srgb, var(--accent2) 80%, #000) 0%, color-mix(in srgb, var(--accent) 70%, #000) 100%)); }
.t-vod::before { background: var(--tile2, linear-gradient(140deg, #3b2d7a, #6b3fa0)); }
.t-series::before { background: var(--tile3, linear-gradient(140deg, #0f5a63, #1d8f80)); }
.tile:hover { transform: scale(1.02); }
.tile:focus { transform: scale(1.03); box-shadow: 0 0 0 3px var(--bg), 0 0 0 7px var(--text), 0 18px 40px rgba(0,0,0,.35); }
.tile-icon { font-size: 2.6rem; margin-bottom: auto; } .tile-label { font-size: 1.7rem; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(26,31,54,.45); } .tile-count { color: rgba(255,255,255,.75); font-weight: 600; }
.chips { display: flex; gap: 12px; flex-wrap: wrap; }
.chip-btn { display: flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; }
.chip-btn:focus, .chip-btn:hover { background: var(--panel2); }
.ci { color: var(--accent); font-size: 1.15rem; }
.acct { display: flex; gap: 28px; flex-wrap: wrap; color: var(--text); font-size: .92rem; padding: 14px 20px; border-radius: var(--r); background: color-mix(in srgb, var(--panel) 70%, transparent); border: 1px solid var(--line); }
.rail h3 { margin: 0 0 10px; font-size: 1.05rem; }
.rail-row { display: flex; gap: 16px; overflow-x: auto; padding: 10px 10px 14px; }
.rail-card:focus { box-shadow: none; }
.rail-card:focus .rail-img { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.rail-card { width: 150px; flex: none; display: flex; flex-direction: column; gap: 6px; border-radius: 12px; padding: 0; }
.rail-img { width: 150px; aspect-ratio: 2/3; border-radius: 12px; }
.rail-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-bar, .bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.rail-bar i, .bar i { display: block; height: 100%; background: var(--accent); }
.rail-bar.wide { max-width: 360px; margin-top: 12px; }

/* ---------- sidebars & lists ---------- */
.live-layout, .grid-layout, .cu-layout, .set-layout, .groups-layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: var(--sidebar); flex: none; border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg2); min-height: 0; }
.cat-search { margin: 12px; width: auto; }
.cat-list { overflow: auto; flex: 1; padding: 0 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar > .cat { margin: 2px 8px; }
.sidebar > .cat:first-child { margin-top: 12px; }
.cat { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; min-height: 44px; }
.cat:hover, .cat:focus { background: var(--panel); }
.cat.active { background: var(--panel2); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .cat.active { box-shadow: inset -3px 0 0 var(--accent); }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock { font-size: .85rem; }
.pane-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex: none; }
.pane-head input { max-width: 360px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.ch-pane { width: 400px; flex: none; display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); min-height: 0; }
.ch-list { overflow: auto; flex: 1; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.ch { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 10px; min-height: 58px; }
.ch:hover, .ch:focus { background: var(--panel); }
.ch.active { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.ch-num { width: 38px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; text-align: end; flex: none; }
.ch-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ch-badges { color: var(--accent); font-size: .85rem; letter-spacing: 3px; }

.pv-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px; gap: 14px; min-height: 0; }
.pv-video-wrap { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--r); overflow: hidden; flex: none; cursor: pointer; }
.pv-video { width: 100%; height: 100%; object-fit: contain; }
.pv-hint { position: absolute; top: auto; left: auto; right: 12px; bottom: 12px; background: rgba(0,0,0,.6); border-radius: 8px; padding: 4px 10px; font-size: .8rem; color: #fff; }
.pv-video-wrap.err::after { content: "⚠"; position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; place-items: center; font-size: 2.4rem; color: var(--accent2); }
.pv-info { display: flex; align-items: center; gap: 12px; flex: none; }
.pv-logo { width: 54px; height: 54px; border-radius: 12px; } .pv-logo img { object-fit: contain; padding: 4px; }
.pv-name { font-weight: 700; font-size: 1.15rem; }
.pv-actions { margin-inline-start: auto; display: flex; gap: 8px; }
.pv-epg { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.epg-row, .prog { display: flex; gap: 14px; padding: 10px 12px; border-radius: 10px; align-items: flex-start; width: 100%; }
.epg-row.now { background: var(--panel); }
.epg-row.past { opacity: .5; }
.prog:hover, .prog:focus { background: var(--panel); }
.prog.dim { opacity: .5; }
.epg-time { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; flex: none; min-width: 60px; }
.epg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.epg-title { font-weight: 600; } .epg-desc { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- poster grid ---------- */
.grid-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.poster-grid { flex: 1; overflow: auto; padding: 14px 20px 28px; display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 18px; align-content: start; }
.poster { position: relative; display: flex; flex-direction: column; gap: 6px; border-radius: 12px; transition: transform .12s; }
.poster:hover { transform: scale(1.03); }
.poster:focus { transform: scale(1.05); box-shadow: none; z-index: 1; }
.poster:focus .poster-img { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.poster:focus .poster-name { color: var(--accent); }
.poster-img { width: 100%; aspect-ratio: 2/3; border-radius: 12px; }
.poster-name { font-size: .88rem; font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rating { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.72); color: #ffd166; font-size: .75rem; padding: 2px 7px; border-radius: 6px; font-weight: 600; }
.fav-dot { position: absolute; top: 8px; right: 8px; color: var(--accent2); background: rgba(0,0,0,.6); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; font-size: .8rem; }
.poster-grid.as-list { grid-template-columns: 1fr; gap: 6px; }
.as-list .poster { flex-direction: row; align-items: center; padding: 6px; }
.as-list .poster:focus { transform: none; background: var(--panel); box-shadow: inset 0 0 0 3px var(--accent); }
.as-list .poster:focus .poster-img { box-shadow: none; }
.as-list .poster-img { width: 54px; } .as-list .rating { position: static; order: 3; margin-inline-start: auto; }
.as-list .rail-bar { width: 120px; order: 4; }
.sentinel { height: 1px; grid-column: 1 / -1; }

/* ---------- details ---------- */
.detail-wrap { flex: 1; overflow: auto; position: relative; }
.detail { position: relative; min-height: 60%; }
.detail-bg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-size: cover; background-position: center top; opacity: .28; mask-image: linear-gradient(to bottom, #000 30%, transparent); -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent); }
.detail-inner { position: relative; display: flex; gap: 34px; padding: 36px 44px; }
.detail-poster { width: 250px; aspect-ratio: 2/3; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.detail-text { flex: 1; min-width: 0; max-width: 900px; }
.detail-title { font-size: 2.2rem; margin: 0 0 12px; line-height: 1.15; }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { padding: 4px 12px; border-radius: 999px; background: var(--panel2); font-size: .85rem; font-weight: 600; }
.pill.dim { color: var(--muted); }
.detail-plot { color: var(--text); opacity: .9; line-height: 1.6; max-width: 760px; }
.meta-row { margin: 6px 0; font-size: .92rem; }
.detail-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.episodes { padding: 0 44px 40px; position: relative; }
.episodes h3 { margin: 0 0 12px; }
.ep-list { display: flex; flex-direction: column; gap: 8px; }
.ep { display: flex; gap: 16px; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); align-items: center; }
.ep:focus, .ep:hover { background: var(--panel2); }
.ep-img { width: 160px; aspect-ratio: 16/9; border-radius: 9px; }
.ep-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ep-title { font-weight: 600; } .ep-plot { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- catch up / search / settings ---------- */
.cu-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px 20px; min-height: 0; }
.prog-list { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.search-wrap { flex: 1; display: flex; flex-direction: column; padding: 20px 28px; gap: 18px; min-height: 0; }
.big-search { font-size: 1.25rem; padding: 16px 20px; border-radius: 14px; max-width: 760px; }
.search-results { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 22px; }
.search-results h3 { margin: 0 0 10px; }
.sr-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; padding: 10px 8px; }
.sr-row.live { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.set-pane { flex: 1; overflow: auto; padding: 18px 28px; display: flex; flex-direction: column; gap: 6px; max-width: 900px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.set-row:focus, .set-row:hover { background: var(--panel2); }
.set-row.static { background: transparent; border-color: transparent; border-bottom: 1px solid var(--line); border-radius: 0; }
.set-val { color: var(--accent); font-weight: 600; text-align: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.about { text-align: center; display: grid; justify-items: center; gap: 4px; padding: 30px; }
.grp-pane { flex: 1; padding: 18px 24px; overflow: auto; }
.grp-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.grp-head h2 { margin: 0; flex: 1; }

/* ---------- player ---------- */
.player { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: #000; z-index: 150; display: none; color: #fff; }
.player.open { display: block; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player[data-aspect="fill"] video { object-fit: cover; }
.player[data-aspect="stretch"] video { object-fit: fill; }
.player[data-aspect="zoom"] video { object-fit: cover; transform: scale(1.15); }
.player video::cue { font-size: var(--sub-size); color: var(--sub-color); background: var(--sub-bg); font-family: system-ui, sans-serif; }
.p-spinner { position: absolute; top: 50%; left: 50%; margin: -27px 0 0 -27px; display: none; border-color: rgba(255,255,255,.2); border-top-color: var(--accent); }
.player.buffering .p-spinner { display: block; }
.p-top, .p-bottom, .p-livebar { position: absolute; left: 0; right: 0; transition: opacity .25s, transform .25s; opacity: 0; pointer-events: none; }
.player.ui .p-top, .player.ui .p-bottom, .player.ui .p-livebar { opacity: 1; pointer-events: auto; }
.p-top { top: 0; padding: 22px 34px 50px; display: flex; justify-content: space-between; background: linear-gradient(rgba(0,0,0,.75), transparent); }
.p-title { font-size: 1.35rem; font-weight: 700; text-shadow: 0 2px 6px #000; }
.p-clock { font-weight: 600; opacity: .85; }
.p-bottom { bottom: 0; padding: 60px 34px 24px; background: linear-gradient(transparent, rgba(0,0,0,.85)); display: flex; flex-direction: column; gap: 12px; }
.p-progress { display: flex; align-items: center; gap: 14px; font-variant-numeric: tabular-nums; }
.p-seek { flex: 1; padding: 0; height: 6px; accent-color: var(--accent); background: transparent; border: 0; }
.p-controls { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pc-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pbtn { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.1); backdrop-filter: blur(6px); color: #fff; }
.pbtn:hover { background: rgba(255,255,255,.25); }
.pbtn:focus { background: rgba(255,255,255,.28); box-shadow: 0 0 0 2px rgba(0,0,0,.6), 0 0 0 4px #fff; }
.pi { font-size: 1.1rem; min-width: 18px; text-align: center; font-weight: 700; }
.pl { font-size: .85rem; }
.p-livebar { bottom: 110px; margin: 0 34px; display: flex; gap: 16px; align-items: center; padding: 16px; border-radius: 16px; background: rgba(10,14,24,.82); backdrop-filter: blur(8px); max-width: 760px; }
.player[data-kind="live"] .p-bottom { padding-top: 20px; }
.lb-logo { width: 64px; height: 64px; border-radius: 12px; } .lb-logo img { object-fit: contain; padding: 4px; }
.lb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-name { font-size: 1.15rem; }
.lb-epg { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.lb-epg .bar { max-width: 360px; background: rgba(255,255,255,.2); }
.tag { background: var(--accent); color: var(--on-accent); padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; }
.tag.dim { background: rgba(255,255,255,.2); color: #fff; }
.p-chlist { position: absolute; top: 0; bottom: 0; left: 0; width: min(420px, 90vw); background: rgba(8,11,20,.94); overflow: auto; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; z-index: 3; }
.chl-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; color: #fff; }
.chl-item.active { background: rgba(255,255,255,.12); }
.chl-item:focus { background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 3px #fff; }
.chl-item .num { width: 34px; opacity: .6; text-align: end; }
.chl-logo { width: 40px; height: 40px; border-radius: 8px; } .chl-logo img { object-fit: contain; }
.p-error { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: none; place-content: center; justify-items: center; text-align: center; gap: 10px; font-size: 1.05rem; padding: 20px; }
.p-error > div { font-size: 3rem; color: var(--accent2); }
.player.err .p-error { display: grid; }

/* ---------- responsive: tablets & phones ---------- */
@media (max-width: 1100px) { .ch-pane { width: 330px; } :root { --sidebar: 220px; } .tiles { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 899px) {
  body { font-size: 15px; }
  .topbar { padding: 10px 14px; }
  .home-head { padding: 18px 16px 4px; } .home-main { padding: 12px 16px 24px; gap: 18px; }
  .tiles { grid-template-columns: 1fr; min-height: 0; } .tile { min-height: 110px; padding: 18px; flex-direction: row; align-items: center; gap: 16px; } .tile-icon { margin: 0; font-size: 2rem; } .tile-label { font-size: 1.3rem; flex: 1; }
  .live-layout, .grid-layout, .cu-layout, .set-layout, .groups-layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 32vh; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .live-layout .sidebar, .grid-layout .sidebar { max-height: none; flex: none; }
  .live-layout .cat-list, .grid-layout .cat-list, .set-layout .sidebar, .cu-layout .cat-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 12px 10px; }
  .set-layout .sidebar { flex-direction: row; overflow-x: auto; padding: 8px; }
  .set-layout .sidebar > .cat { margin: 0 2px; }
  .live-layout .cat, .grid-layout .cat, .set-layout .cat, .cu-layout .cat { flex: none; white-space: nowrap; border-radius: 999px; background: var(--panel); min-height: 38px; padding: 8px 14px; }
  .cat .cat-name { overflow: visible; }
  .cat-search { margin: 10px 12px 8px; }
  .ch-pane { width: 100%; flex: 1; border: 0; } .pv-pane { display: none; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; padding: 4px 12px 20px; }
  .detail-inner { flex-direction: column; padding: 18px 16px; gap: 18px; } .detail-poster { width: 150px; } .detail-title { font-size: 1.5rem; }
  .episodes { padding: 0 16px 30px; } .ep-img { width: 110px; }
  .p-top { padding: 14px 16px 40px; } .p-bottom { padding: 40px 12px 14px; } .pl { display: none; } .p-livebar { margin: 0 12px; bottom: 90px; }
  .cu-layout .sidebar { max-height: none; }
}

.err-msg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, monospace; font-size: .88rem; word-break: break-word; margin: 0 0 12px; }
.row-gap.center { justify-content: center; flex-wrap: wrap; gap: 12px; }

/* Older Android WebViews (TV boxes) lack aspect-ratio and flex gap: give fixed-ratio boxes a padding-based height instead */
@supports not (aspect-ratio: 1 / 1) {
  .poster-img, .rail-img, .detail-poster { height: 0; padding-top: 150%; }
  .pv-video-wrap, .yt, .ep-img { height: 0; padding-top: 56.25%; }
  .pv-video-wrap video, .yt iframe { position: absolute; top: 0; left: 0; }
  .detail-poster { padding-top: 0; height: 375px; }
  .tiles > *, .chips > *, .detail-actions > *, .pc-group > *, .tb-actions > *, .row-gap > * { margin: 0 6px 6px 0; }
}
.web-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }

/* ---------- Add from phone ---------- */
.phone-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border: 1px dashed var(--accent); font-weight: 600; }
.pair-wrap { flex: 1; overflow: auto; display: flex; gap: 48px; align-items: center; justify-content: center; padding: 28px max(24px, env(safe-area-inset-left, 0px)); flex-wrap: wrap; }
.pair-card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box { width: min(300px, 42vh); height: min(300px, 42vh); flex: none; border-radius: 16px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-off { font-size: 4rem; filter: grayscale(1); }
.pair-code-label { margin-top: 10px; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pair-code { font-size: 2.6rem; font-weight: 700; letter-spacing: .28em; font-variant-numeric: tabular-nums; color: var(--accent); padding-left: .28em; }
.pair-info { max-width: 520px; display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.pair-info h2 { margin: 0; font-size: 1.7rem; text-wrap: balance; }
.pair-steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 12px; line-height: 1.5; }
[dir="rtl"] .pair-steps { padding-left: 0; padding-right: 1.4em; }
.qr-url { margin-top: 6px; font-family: ui-monospace, monospace; font-size: 1.05rem; color: var(--accent); word-break: break-all; }
.pair-status { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.pair-status.bad { border-color: var(--accent2); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.pair-status.bad .pulse { display: none; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
@media (max-width: 899px) { .qr-box { width: 220px; height: 220px; } .pair-wrap { gap: 24px; } .pair-code { font-size: 2rem; } }

/* phone sender (published page opened from the QR code) */
.screen-send { overflow: auto; }
.send-wrap { width: min(460px, 100%); margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left, 0px)) 40px; display: flex; flex-direction: column; gap: 16px; }
.send-head { display: flex; gap: 12px; align-items: center; } .send-head h1 { margin: 0; font-size: 1.25rem; }
.send-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.send-card .tabs { margin: 0; }
#send-code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.send-btn { width: 100%; justify-content: center; text-align: center; }
.send-msg:empty { display: none; }
.send-msg { padding: 12px 14px; border-radius: 11px; font-size: .92rem; background: var(--panel2); }
.send-msg.ok { border: 1px solid #7fd6a4; } .send-msg.bad { border: 1px solid var(--accent2); }

/* raised, softly lit cards for the themes that define --elev (sculpted look) */
.tile:not(:focus), .pl-card, .set-row:not(.static):not(:focus), .ep:not(:focus), .acct, .chip-btn:not(:focus), .pair-card, .send-card, .icon-btn:not(:focus), .btn:not(.primary):not(:focus), .tab:not(.active):not(:focus) { box-shadow: var(--elev, none); }
.poster-img, .rail-img, .detail-poster, .pv-video-wrap { box-shadow: var(--elev, none); }

/* ================= Layout styles 2–5 ================= */
.eyebrow { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.acct-mini { padding: 4px 2px; }
.chan-chip { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 120px; padding: 12px 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); flex: none; }
.chan-chip-logo { width: 64px; height: 64px; border-radius: 14px; } .chan-chip-logo img { object-fit: contain; padding: 4px; }
.chan-chip-name { font-size: .82rem; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 3 · Side rail */
.side-layout { flex: 1; display: flex; min-height: 0; }
.side-rail { width: 260px; flex: none; display: flex; flex-direction: column; gap: 22px; padding: 26px 16px; background: var(--bg2); border-inline-end: 1px solid var(--line); }
.side-items { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; font-weight: 600; }
.side-item:hover { background: var(--panel); }
.side-item:focus { box-shadow: inset 0 0 0 3px var(--accent); background: var(--panel); }
.side-ic { width: 36px; height: 36px; border-radius: 11px; background: var(--panel2); display: grid; place-items: center; color: var(--accent); flex: none; }
.side-label { flex: 1; } .side-count { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.side-main { flex: 1; min-width: 0; overflow: auto; padding: 28px 36px; display: flex; flex-direction: column; gap: 24px; }
.side-hello { display: flex; justify-content: space-between; align-items: flex-end; }
.side-hello h2 { margin: 4px 0 0; font-size: 2rem; }
/* 5 · Rails */
.rails-head { display: flex; align-items: center; gap: 22px; padding: 18px 40px; flex: none; }
.rails-head .brand-name { font-weight: 800; font-size: 1.3rem; }
.top-tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top-tab { padding: 10px 16px; border-radius: 999px; font-weight: 600; white-space: nowrap; color: var(--muted); }
.top-tab:hover { color: var(--text); background: var(--panel); }
.top-tab:focus { color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 3px var(--accent); }
.rails-main { padding-top: 6px; }
.feature { position: relative; display: flex; align-items: center; gap: 30px; padding: 34px 40px; border-radius: 26px; overflow: hidden; background: var(--slate, #24302E); color: #fff; min-height: 270px; box-shadow: var(--elev, none); }
.feature-bg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-size: cover; background-position: center; filter: blur(28px) saturate(1.1); transform: scale(1.2); opacity: .55; }
.feature::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: linear-gradient(90deg, rgba(20,26,25,.85), rgba(20,26,25,.35)); }
.feature-body { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.feature-body .eyebrow { color: #F2D3B3; } .feature-body h2 { margin: 0; font-size: 2.6rem; line-height: 1.05; } .feature-meta { color: rgba(255,255,255,.75) !important; }
.feature-poster { position: relative; z-index: 1; width: 150px; aspect-ratio: 2/3; border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
@media (max-width: 899px) {
  .side-layout { flex-direction: column; } .side-rail { width: 100%; padding: 14px; gap: 10px; } .side-items { flex-direction: row; overflow-x: auto; } .side-item { flex: none; } .side-count, .side-rail .acct-mini { display: none; } .side-main { padding: 16px; }
  .rails-head { padding: 12px 16px; flex-wrap: wrap; } .feature { padding: 22px; } .feature-poster { display: none; } .feature-body h2 { font-size: 1.8rem; }
}
/* secondary buttons sitting on the dark/colour hero banners */
.feature .btn:not(.primary) { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.35); box-shadow: none; }
.feature .btn:not(.primary):focus { box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 0 5px #fff; }
.feature-body .btn.primary:focus { box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 0 5px #fff; }

/* Continue Watching as a small grid of posters */
.resume-grid .rail-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 14px; overflow: visible; padding: 8px 4px 4px; }
.resume-grid .rail-card { width: auto; }
.resume-grid .rail-img { width: 100%; border-radius: 10px; }
.resume-grid .rail-name { font-size: .8rem; }

/* Last added rows: scroll arrows, focused card grows a little */
.latest-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.latest-head h3 { margin: 0; }
.rail-arrows { margin-inline-start: auto; display: flex; gap: 8px; }
.rail-arrow { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--panel); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; user-select: none; }
.rail-arrow:hover { background: var(--accent); color: var(--on-accent, #fff); }
.rail-arrow.off { opacity: .35; pointer-events: none; }
.rail-row { scroll-behavior: smooth; scrollbar-width: none; }
.rail-row::-webkit-scrollbar { display: none; }
.latest-row { padding: 14px 16px 18px; }
.latest + .latest { margin-top: 4px; }
.rail-card { transition: transform .18s ease; transform-origin: center center; }
.rail-card:focus, .rail-card:hover { transform: scale(1.08); position: relative; z-index: 1; }
.rail-card:focus .rail-name { color: var(--text); font-weight: 600; }
@media (hover: none) { .rail-arrows { display: none; } }

/* tappable favourite star on channel rows (small screens only) */
.ch-star { display: none; margin-inline-start: auto; flex: none; width: 44px; height: 44px; place-items: center; border-radius: 50%; font-size: 1.35rem; color: var(--muted); cursor: pointer; }
.ch-star.on { color: var(--accent); }
.ch-star:active { background: var(--panel2); }
@media (max-width: 899px) { .ch-star { display: grid; } .fav-b { display: none; } }
.fav-b { font-style: normal; }

/* pairing screen always fits one screen (TVs have no scrolling by touch) */
.pair-wrap { flex-wrap: nowrap; }
@media (max-width: 899px) { .pair-wrap { flex-wrap: wrap; } }
@media (max-height: 600px) and (min-width: 900px) { .pair-wrap { gap: 32px; padding-block: 16px; } .pair-card { padding: 18px; } .pair-code { font-size: 2rem; } .pair-info h2 { font-size: 1.35rem; } .pair-steps { gap: 8px; } }
