/* ==========================================================================
   Supreme Player design system
   Tokens -> base -> layout -> components -> views -> player
   ========================================================================== */

:root {
  --bg: #0b0d12;
  --surface: #131722;
  --surface-2: #1a2030;
  --surface-3: #232b3f;
  --border: #252c3e;
  --text: #e9edf6;
  --muted: #8d97ad;
  --accent: #6f8dff;
  --accent-strong: #4f6fef;
  --accent-ink: #fff;
  --danger: #ff6272;
  --ok: #3ddc97;
  --warn: #ffb648;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --tabbar-h: calc(60px + env(safe-area-inset-bottom));
  --gutter: clamp(14px, 3vw, 28px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --surface-3: #e2e7f2;
  --border: #dbe1ee;
  --text: #141a29;
  --muted: #5d6882;
  --accent: #4463f0;
  --accent-strong: #2f4bd8;
  --shadow: 0 10px 40px rgba(30, 45, 90, .16);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.lg { width: 28px; height: 28px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: inherit;
  transition: background .15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.icon-btn.on { color: var(--warn); }
.icon-btn.on svg.i { fill: currentColor; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); outline: none; }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238d97ad' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.search-input { position: relative; flex: 1; min-width: 0; }
.cats > .search-input, .live-cats > .search-input { flex: none; }
.search-input > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input .input { padding-left: 42px; min-height: 42px; border-radius: 999px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; transition: background .2s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px var(--gutter); margin: 0 calc(var(--gutter) * -1); scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--muted); letter-spacing: .02em; }
.badge-live { background: var(--danger); color: #fff; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); padding: 20px 14px; display: none; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; padding: 4px 10px 18px; white-space: nowrap; }
.brand { text-decoration: none; }
.brand-logo { display: block; height: 64px; width: auto; }
.sidebar .brand { justify-content: center; padding: 0 10px 12px; }
.login-card .brand { justify-content: center; }
.login-card .brand-logo { height: 96px; }
.topbar-logo { display: inline-flex; align-items: center; flex: none; }
.topbar-logo img { height: 34px; width: auto; display: block; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); font-weight: 600;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.sidebar .spacer { flex: 1; }
.account-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.account-chip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; flex: none; }
.account-chip small { display: block; color: var(--muted); font-size: 12px; }
.account-chip div { min-width: 0; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--gutter) 0;
  display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; flex: 1; min-width: 0; }
.topbar .brand { padding: 0; flex: 1; }
.view { padding: 18px var(--gutter) calc(var(--tabbar-h) + 24px); animation: fade .25s ease; }
.view.flush { padding: 0; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; inset: auto 0 0 0; height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom); z-index: 40; display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); min-width: 0; }
.tab.active { color: var(--accent); }
.tab svg.i { width: 24px; height: 24px; }

@media (max-width: 959.98px) { .only-desktop { display: none !important; } }
@media (min-width: 960px) {
  .sidebar { display: flex; }
  .main { margin-left: var(--sidebar-w); }
  .tabbar { display: none; }
  .only-mobile { display: none !important; }
  .view { padding-bottom: 40px; }
  :root { --tabbar-h: 0px; }
  .topbar .brand { display: none; }
}

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), radial-gradient(900px 500px at 100% 110%, color-mix(in srgb, #8a4dff 18%, transparent), transparent 60%), var(--bg); }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.login-card .brand { padding: 0; font-size: 24px; }
.login-card p.lead { color: var(--muted); margin-top: -8px; }
.login form { display: grid; gap: 14px; }
.pw { position: relative; }
.pw .icon-btn { position: absolute; right: 2px; top: 1px; width: 44px; height: 44px; color: var(--muted); }
.pw .input { padding-right: 48px; }
.error-box { padding: 11px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 14%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); font-size: 14px; }
.saved { display: grid; gap: 8px; }
.saved-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); text-align: left; width: 100%; }
.saved-item:hover { border-color: var(--accent); }
.saved-item .grow { flex: 1; min-width: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- section headers, rows, cards ---------- */
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.section-head a, .section-head button { color: var(--accent); font-size: 13px; font-weight: 600; }
.row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter); padding: 2px var(--gutter) 10px; margin: 0 calc(var(--gutter) * -1); scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.row > * { scroll-snap-align: start; flex: none; }
.row .card { width: clamp(118px, 30vw, 158px); }
.row .card.wide { width: clamp(200px, 60vw, 280px); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(112px, 29vw, 172px), 1fr)); gap: 18px 14px; }
.card { display: block; position: relative; min-width: 0; border-radius: var(--radius-sm); }
.card-img {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius-sm); overflow: hidden; background: linear-gradient(160deg, var(--surface-3), var(--surface-2));
  display: grid; place-items: center; transition: transform .2s, box-shadow .2s;
}
.card.wide .card-img { aspect-ratio: 16 / 9; }
.card-img::before { content: attr(data-initial); position: absolute; font-size: 34px; font-weight: 800; color: var(--muted); opacity: .5; }
.card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.card-img img.loaded { opacity: 1; }
.card-img img.broken { display: none; }
@media (hover: hover) { .card:hover .card-img { transform: translateY(-3px); box-shadow: var(--shadow); } }
.card-title { margin-top: 8px; font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card .rating { position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; font-weight: 700; display: flex; gap: 4px; align-items: center; }
.card .rating svg { width: 11px; height: 11px; fill: var(--warn); stroke: none; }
.card .fav-btn { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .15s; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.card:hover .fav-btn, .card .fav-btn.on, .card .fav-btn:focus-visible { opacity: 1; }
@media (hover: none) { .card .fav-btn { opacity: 1; } }
.card .fav-btn.on { color: var(--warn); }
.card .fav-btn.on svg.i { fill: currentColor; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.25); }
.progress > i { display: block; height: 100%; background: var(--accent); }

.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 96px; text-align: center; }
.tile .logo { width: 84px; height: 84px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; padding: 10px; position: relative; overflow: hidden; }
.tile .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .logo img.broken { display: none; }
.tile .logo::before { content: attr(data-initial); position: absolute; font-weight: 800; color: var(--muted); font-size: 24px; opacity: .6; }
.tile .logo img { position: relative; }
.tile span { font-size: 12px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; width: 100%; }

.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card .skeleton:first-child { aspect-ratio: 2/3; }
.skel-card .skeleton:last-child { height: 14px; margin-top: 10px; width: 70%; }

.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 56px 20px; color: var(--muted); }
.empty svg.i { width: 44px; height: 44px; opacity: .6; }
.empty h3 { color: var(--text); font-size: 17px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--text) 18%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; gap: 14px; padding: 60px 0; color: var(--muted); }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: 14px; }
.banner.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- category lists / two-pane browse ---------- */
.pane { display: block; }
.cats { display: none; }
.cat-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.cat-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; text-align: left; width: 100%; }
.cat-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item small { font-size: 12px; opacity: .75; flex: none; }
.cat-item:hover { background: var(--surface-2); color: var(--text); }
.cat-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.cat-item .i { width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .btn { min-height: 42px; }
.toolbar select.input { width: auto; min-height: 42px; border-radius: 999px; padding-left: 16px; }
.count { color: var(--muted); font-size: 13px; }
@media (max-width: 959.98px) { .toolbar.stack .search-input { flex: 1 1 100%; order: -1; } .toolbar.stack select.input { flex: 1; } }

@media (min-width: 960px) {
  .pane { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 26px; align-items: start; }
  .cats { display: flex; flex-direction: column; position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100dvh - var(--topbar-h) - 32px); gap: 10px; }
  .cat-btn { display: none !important; }
}

/* ---------- sheet / modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(4, 6, 12, .62); display: flex; align-items: flex-end; justify-content: center; animation: fadein .18s ease; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes fadein { from { opacity: 0; } }
.sheet { width: min(560px, 100%); max-height: min(82dvh, 720px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 22px 22px 0 0; box-shadow: var(--shadow); animation: rise .24s cubic-bezier(.2, .8, .2, 1); padding-bottom: env(safe-area-inset-bottom); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 20px; }
.sheet-head h3 { flex: 1; font-size: 17px; }
.sheet-body { padding: 4px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; animation: rise .22s ease; pointer-events: auto; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 60%, transparent); }

/* ---------- LIVE view ---------- */
.live { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top) - var(--tabbar-h)); }
.live-stage { display: none; background: var(--bg); }
.live.has-channel .live-stage { display: block; }
.live-list { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 12px var(--gutter) 0; gap: 10px; }
.live-stage .xp { max-height: 46dvh; }
.live-cats { display: none; }
.vl { position: relative; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.vl-spacer { position: relative; width: 100%; }
.vl-window { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.ch { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 8px 0 6px; border-radius: 12px; width: 100%; text-align: left; }
.ch:hover { background: var(--surface-2); }
.ch.active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ch .logo { width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; padding: 4px; position: relative; overflow: hidden; }
.ch .logo img { max-width: 100%; max-height: 100%; object-fit: contain; position: relative; }
.ch .logo img.broken { display: none; }
.ch .logo::before { content: attr(data-initial); position: absolute; font-weight: 800; color: var(--muted); opacity: .6; }
.ch .meta { flex: 1; min-width: 0; }
.ch .name { font-weight: 600; display: block; }
.ch .num { color: var(--muted); font-size: 12px; }
.ch .fav { width: 40px; height: 40px; color: var(--muted); border-radius: 50%; display: grid; place-items: center; flex: none; }
.ch .fav:hover { color: var(--text); }
.ch .fav.on { color: var(--warn); }
.ch .fav.on svg.i { fill: currentColor; }
.ch .playing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.stage-info { padding: 12px var(--gutter) 10px; display: grid; gap: 10px; }
.stage-title { display: flex; align-items: center; gap: 10px; }
.stage-title h2 { font-size: 17px; flex: 1; min-width: 0; }
.epg-now .t { font-weight: 600; }
.epg-now .s { color: var(--muted); font-size: 13px; }
.epg-bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin: 6px 0; }
.epg-bar > i { display: block; height: 100%; background: var(--accent); }
.epg-list { display: none; }
.epg-item { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.epg-item time { color: var(--muted); font-variant-numeric: tabular-nums; }
.epg-item p { color: var(--muted); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* mobile: sticky player above channel list */
@media (max-width: 959.98px) {
  .live.has-channel .live-stage { position: relative; }
  .live .xp { border-radius: 0; }
  .live-stage .stage-actions .only-desktop { display: none; }
  .live-stage .epg-list { display: none !important; }
}
@media (min-width: 960px) {
  .live { display: grid; grid-template-rows: 1fr; grid-template-columns: 232px minmax(280px, 360px) minmax(0, 1fr); gap: 0; height: calc(100dvh - var(--topbar-h)); }
  .live-cats { display: flex; flex-direction: column; min-height: 0; padding: 14px 8px 0 var(--gutter); gap: 8px; border-right: 1px solid var(--border); }
  .live-cats .cat-list { flex: 1; padding-bottom: 20px; }
  .live-list { padding: 14px 10px 0; border-right: 1px solid var(--border); }
  .live-stage { display: block; overflow-y: auto; order: 3; padding: 16px var(--gutter); }
  .live-stage .xp { border-radius: var(--radius); max-height: none; }
  .stage-info { padding: 16px 2px; }
  .epg-list { display: block; }
  .stage-empty { display: grid; }
}
.stage-empty { display: none; place-items: center; text-align: center; color: var(--muted); gap: 10px; height: 100%; min-height: 320px; }
.stage-empty svg.i { width: 56px; height: 56px; opacity: .45; }
.live.has-channel .stage-empty { display: none; }
.live:not(.has-channel) .stage-body { display: none; }
@media (min-width: 960px) { .live .live-stage { display: block; } }

/* ---------- detail pages ---------- */
.detail-hero { position: relative; margin: -18px calc(var(--gutter) * -1) 0; padding: 18px var(--gutter) 24px; overflow: hidden; isolation: isolate; }
.detail-hero .backdrop { position: absolute; inset: 0; z-index: -1; background-size: cover; background-position: center 20%; opacity: .22; filter: blur(2px) saturate(1.2); transform: scale(1.05); }
.detail-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, transparent 30%, var(--bg)); }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; margin-bottom: 14px; min-height: 40px; }
.back-link:hover { color: var(--text); }
.detail { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.detail-poster { width: min(46vw, 210px); aspect-ratio: 2/3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); position: relative; }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-poster img.broken { display: none; }
.detail-main { display: grid; gap: 14px; align-content: start; min-width: 0; width: 100%; }
.detail-main h1 { font-size: clamp(24px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.meta-line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 14px; }
.meta-line .rate { color: var(--warn); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.meta-line .rate svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.plot { max-width: 70ch; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; max-width: 70ch; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (min-width: 720px) { .detail { grid-template-columns: 210px minmax(0, 1fr); gap: 32px; } .detail-poster { width: 100%; } }
@media (max-width: 719.98px) { .detail-poster { justify-self: start; } }

.episodes { display: grid; gap: 10px; margin-top: 8px; }
.episode { display: grid; grid-template-columns: 118px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-align: left; width: 100%; transition: border-color .15s, background .15s; }
.episode:hover { border-color: var(--accent); background: var(--surface-2); }
.ep-thumb { position: relative; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.ep-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ep-thumb img.broken { display: none; }
.ep-body { min-width: 0; }
.ep-body strong { display: block; font-size: 14px; }
.ep-body p { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.ep-check { color: var(--ok); }
@media (max-width: 520px) { .episode { grid-template-columns: 96px minmax(0, 1fr); } .episode > .ep-check { display: none; } }

/* ---------- settings ---------- */
.settings { display: grid; gap: 22px; max-width: 760px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 18px; }
.panel > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 0 4px; }
.panel .line { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border); }
.panel h3 + .line { border-top: 0; }
.panel .line small { display: block; color: var(--muted); }
.panel .line select.input { width: auto; min-width: 150px; }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; padding: 10px 0 14px; font-size: 14px; }
kbd { display: inline-block; min-width: 24px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); font: 600 12px/1.6 ui-monospace, monospace; text-align: center; }

/* ==========================================================================
   Player
   ========================================================================== */
.xp { position: relative; background: #000; color: #fff; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; aspect-ratio: 16 / 9; width: 100%; --xp-accent: var(--accent); }
.xp video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.xp-full { position: fixed; inset: 0; z-index: 90; aspect-ratio: auto; height: 100dvh; }
.xp:fullscreen, .xp:-webkit-full-screen { max-height: none !important; aspect-ratio: auto; width: 100vw; height: 100dvh; border-radius: 0 !important; }
.xp.is-fs { position: fixed; inset: 0; width: 100vw; height: 100dvh; aspect-ratio: auto; border-radius: 0 !important; z-index: 9999; }
.xp-surface { position: absolute; inset: 0; z-index: 1; }
.xp-top, .xp-controls { position: absolute; left: 0; right: 0; z-index: 3; transition: opacity .22s; }
.xp-top { top: 0; padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 28px calc(8px + env(safe-area-inset-left)); display: flex; align-items: center; gap: 6px; background: linear-gradient(rgba(0,0,0,.7), transparent); }
.xp-top .titles { min-width: 0; flex: 1; }
.xp-top strong { display: block; font-size: 16px; }
.xp-top small { opacity: .75; }
.xp-embed .xp-top { display: none; }
.xp-controls { bottom: 0; padding: 34px calc(10px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); background: linear-gradient(transparent, rgba(0,0,0,.82)); }
.xp.idle .xp-top, .xp.idle .xp-controls { opacity: 0; pointer-events: none; }
.xp.idle { cursor: none; }
.xp .icon-btn { width: 42px; height: 42px; color: #fff; }
.xp .icon-btn:hover { background: rgba(255,255,255,.16); }
.xp-row { display: flex; align-items: center; gap: 2px; }
.xp-row .grow { flex: 1; }
.xp-time { font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 8px; white-space: nowrap; opacity: .95; }
.xp .badge-live { margin: 0 8px; }
.xp-seek { display: block; width: 100%; height: 22px; margin: 0 0 2px; appearance: none; background: transparent; cursor: pointer; --p: 0%; --b: 0%; touch-action: none; }
.xp-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--xp-accent) var(--p), rgba(255,255,255,.55) var(--p), rgba(255,255,255,.55) var(--b), rgba(255,255,255,.22) var(--b)); }
.xp-seek::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--xp-accent) var(--p), rgba(255,255,255,.55) var(--p), rgba(255,255,255,.55) var(--b), rgba(255,255,255,.22) var(--b)); }
.xp-seek::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; box-shadow: 0 0 0 4px rgba(255,255,255,.2); transform: scale(0); transition: transform .12s; }
.xp-seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; transform: scale(0); transition: transform .12s; }
.xp-seek:hover::-webkit-slider-thumb, .xp-seek:focus-visible::-webkit-slider-thumb, .xp.seeking .xp-seek::-webkit-slider-thumb { transform: scale(1); }
.xp-seek:hover::-moz-range-thumb, .xp-seek:focus-visible::-moz-range-thumb, .xp.seeking .xp-seek::-moz-range-thumb { transform: scale(1); }
.xp.is-live .xp-seek, .xp.is-live .xp-vod-only { display: none; }
.xp-vol { width: 84px; height: 22px; appearance: none; background: transparent; cursor: pointer; --p: 100%; margin: 0 6px; }
.xp-vol::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, #fff var(--p), rgba(255,255,255,.3) var(--p)); }
.xp-vol::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, #fff var(--p), rgba(255,255,255,.3) var(--p)); }
.xp-vol::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; margin-top: -4.5px; }
.xp-vol::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
@media (pointer: coarse), (max-width: 620px) { .xp-vol { display: none; } .xp-row .vol-btn-wrap .icon-btn { display: none; } }
.xp-center { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; }
.xp-bigplay { width: 68px; height: 68px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; transition: transform .2s, opacity .2s; pointer-events: auto; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.xp-bigplay svg { width: 30px; height: 30px; }
.xp:not(.paused) .xp-bigplay, .xp.buffering .xp-bigplay, .xp.errored .xp-bigplay { opacity: 0; transform: scale(.8); pointer-events: none; }
.xp .spinner { display: none; width: 44px; height: 44px; border-width: 4px; border-color: rgba(255,255,255,.25); border-top-color: #fff; position: absolute; }
.xp.buffering:not(.errored) .spinner { display: block; }
.xp-toast { position: absolute; z-index: 4; left: 50%; top: 18%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: rgba(0,0,0,.7); font-size: 14px; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity .2s; white-space: nowrap; }
.xp-toast.show { opacity: 1; }
.xp-error { position: absolute; inset: 0; z-index: 5; display: none; place-items: center; align-content: center; gap: 12px; text-align: center; padding: 24px; background: rgba(0,0,0,.82); }
.xp.errored .xp-error { display: grid; }
.xp.errored video { visibility: hidden; }
.xp-error p { max-width: 42ch; opacity: .9; }
.xp-error .actions { justify-content: center; }
.xp-error .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.xp-error .btn-primary { background: var(--accent); }
.xp-menu { position: absolute; z-index: 6; right: 10px; bottom: 74px; width: min(300px, calc(100% - 20px)); max-height: calc(100% - 100px); overflow-y: auto; background: rgba(16, 19, 28, .96); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 8px; box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.xp-menu h4 { margin: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; opacity: .6; }
.xp-menu button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 40px; padding: 0 10px; border-radius: 10px; text-align: left; font-size: 14px; }
.xp-menu button:hover { background: rgba(255,255,255,.1); }
.xp-menu button.sel { color: var(--accent); font-weight: 700; }
.xp-menu button.sel::after { content: "\2713"; }
.xp-embed .xp-menu { bottom: 62px; }
.xp-flash { position: absolute; top: 0; bottom: 0; width: 34%; z-index: 2; display: grid; place-items: center; pointer-events: none; opacity: 0; background: radial-gradient(closest-side, rgba(255,255,255,.22), transparent); font-weight: 700; }
.xp-flash.left { left: 0; } .xp-flash.right { right: 0; }
.xp-flash.show { animation: flash .5s ease; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- reconnect status, connections badge, update bar ---------- */
.xp-status { position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%); max-width: 90%; padding: 7px 14px; border-radius: 999px; background: rgba(0,0,0,.72); color: #fff; font-size: 13px; font-weight: 600; text-align: center; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.xp-status[hidden] { display: none; }
.conn-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.conn-badge[hidden] { display: none; }
.conn-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.conn-badge.full .dot { background: var(--warn); }
.conn-badge.over .dot { background: var(--danger); }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 12px); z-index: 300; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 999px; background: var(--surface-3); border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: var(--shadow); font-size: 14px; max-width: calc(100vw - 24px); animation: drop .22s ease; }
@keyframes drop { from { transform: translate(-50%, -30px); opacity: .4; } }
.update-bar[hidden] { display: none; }
.update-bar .btn { padding: 6px 14px; }
