/* Web player (player/index.php): the look of WPlayer by @tealcavalon. The panel's Settings > Themes
   sets --accent and --red (main and second color) and light or dark (index.php); the rest follows them. */
:root {
  --bg: #07080b; --bg-2: #12141c; --bg-3: #1a1e2a; --border: #242a3a; --top-2: #0d0f16;
  --text: #e9edf5; --dim: #8892a6; --accent: #29aaff; --red: #ff2d4d; --danger: #ff4f6d; --err-text: #fecaca; --r: 10px;
  --accent-dim: color-mix(in srgb, var(--accent) 28%, var(--bg)); --glow: color-mix(in srgb, var(--accent) 35%, transparent);
  --red-dim: color-mix(in srgb, var(--red) 24%, var(--bg)); --red-glow: color-mix(in srgb, var(--red) 35%, transparent);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f6fb; --bg-2: #ffffff; --bg-3: #eef2f8; --border: #dfe6f0; --top-2: #f7f9fc;
    --text: #0f172a; --dim: #5b6b85; --danger: #dc2626; --err-text: #991b1b;
  }
}
:root[data-theme="light"] {
  --bg: #f3f6fb; --bg-2: #ffffff; --bg-3: #eef2f8; --border: #dfe6f0; --top-2: #f7f9fc;
  --text: #0f172a; --dim: #5b6b85; --danger: #dc2626; --err-text: #991b1b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-3); padding: 8px 14px; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover, button:focus-visible { background: var(--accent-dim); border-color: var(--accent); box-shadow: 0 0 12px var(--glow); outline: none; }
button.primary { background: linear-gradient(90deg, var(--accent-dim), var(--red-dim)); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: linear-gradient(90deg, var(--accent), var(--red)); color: #0a0b0f; }
.ghost { background: transparent; }
input[type=search], input[type=text], input[type=password], select { padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg); width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse 700px 500px at 20% 15%, color-mix(in srgb, var(--red) 12%, transparent), transparent 60%), radial-gradient(ellipse 700px 500px at 80% 85%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%), var(--bg); }
.login form { width: min(380px, 100%); display: grid; gap: 12px; background: color-mix(in srgb, var(--bg-2) 75%, transparent); border: 1px solid var(--border); border-radius: 14px; padding: 26px; box-shadow: 0 0 50px color-mix(in srgb, var(--accent) 8%, transparent), 0 0 80px color-mix(in srgb, var(--red) 5%, transparent); }
.login-logo { display: block; max-width: 100%; max-height: 150px; margin: 0 auto; object-fit: contain; }
.login h1 { margin: 0; font-size: 24px; text-align: center; letter-spacing: .04em; }
.login .muted { text-align: center; }
.login input { padding: 12px 14px; }
.err { color: var(--err-text); background: color-mix(in srgb, var(--danger) 15%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); padding: 9px 12px; border-radius: var(--r); }
.captcha { display: flex; gap: 8px; align-items: center; }
.captcha img { width: 100%; max-width: 300px; height: auto; border-radius: var(--r); border: 1px solid var(--border); background: #eef; }
.credit { display: block; text-align: center; color: var(--dim); font-size: 12px; text-decoration: none; }
.credit:hover { color: var(--text); }
.muted { color: var(--dim); }

/* App */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: radial-gradient(ellipse 900px 500px at 15% -10%, color-mix(in srgb, var(--red) 8%, transparent), transparent 60%), radial-gradient(ellipse 900px 500px at 100% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%), var(--bg); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: linear-gradient(180deg, var(--bg-2), var(--top-2)); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { height: 44px; max-width: 200px; object-fit: contain; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .06em; white-space: nowrap; text-shadow: 0 0 10px var(--red-glow), 0 0 14px var(--glow); }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border-color: transparent; color: var(--dim); font-weight: 600; }
.tab.on { color: var(--text); border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 12px var(--glow); }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 420px; }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); max-height: 60vh; overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .6); }
.results h4 { margin: 0; padding: 8px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.result { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; padding: 7px 12px; }
.result img { width: 28px; height: 40px; object-fit: cover; border-radius: 4px; background: #000; flex: none; }
.account { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; margin-left: auto; flex-wrap: wrap; }
.icon-btn { padding: 8px 10px; }

.layout { display: flex; flex: 1; min-height: 0; position: relative; }
.sidebar { width: 320px; flex: none; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; transition: margin-left .2s; }
.sidebar.collapsed { margin-left: -320px; }
/* The list folded: a tab on the left edge opens it again. */
.open-list { display: none; position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 20; padding: 14px 7px; border-radius: 0 var(--r) var(--r) 0; border-left: 0; background: var(--accent-dim); border-color: var(--accent); box-shadow: 0 0 12px var(--glow); font-weight: 600; font-size: 13px; }
.open-list span { writing-mode: vertical-rl; transform: rotate(180deg); }
.sidebar.collapsed ~ .open-list { display: block; }
/* A movie or an episode: the player alone. */
.layout.vod .sidebar, .layout.vod .open-list { display: none !important; }
.sidebar-controls { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.count { padding: 8px 12px; font-size: 12px; color: var(--dim); border-bottom: 1px solid var(--border); }
.channels { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; position: relative; }
.spacer { display: block; pointer-events: none; }
/* Rows are exactly ROW px tall (player.js): only those near the view exist. */
.ch { position: absolute; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; overflow: hidden; }
.ch:hover, .ch.focus { background: var(--bg-3); }
.ch.on { background: var(--accent-dim); border-left-color: var(--accent); box-shadow: inset 0 0 20px var(--glow); }
.ch img, .ch .ph { width: 36px; height: 36px; object-fit: contain; background: #000; border-radius: 4px; flex: none; }
.ch .ph { display: grid; place-items: center; color: var(--dim); }
.ch .meta { min-width: 0; flex: 1; }
.ch .name, .ch .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .name { font-size: 13.5px; }
.ch .sub { font-size: 11px; color: var(--dim); }
.progress { height: 3px; background: var(--border); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--red)); }
.star { background: transparent; border: 0; padding: 4px; color: var(--dim); font-size: 16px; box-shadow: none !important; }
.star.on { color: #ffd34d; }

.player-area { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 16px; gap: 12px; }
.video-wrap { position: relative; flex: 1; min-height: 0; background: #000; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
#video { width: 100%; height: 100%; background: #000; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--dim); background: rgba(0, 0, 0, .45); pointer-events: none; }
.overlay.error { color: var(--danger); }
.overlay button { pointer-events: auto; }
.player-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.now { color: var(--dim); }
.now strong { color: var(--text); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions select { width: auto; }

/* Movies and series */
.browse { flex: 1; overflow-y: auto; padding: 16px; }
.browse-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.browse-bar input, .browse-bar select { max-width: 320px; }
.row-title { margin: 18px 0 8px; font-size: 15px; font-weight: 700; }
.row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { position: relative; flex: none; width: 150px; padding: 0; text-align: left; overflow: hidden; border-radius: var(--r); background: var(--bg-2); scroll-snap-align: start; }
.grid .card { width: auto; }
.card img, .card .noposter { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; background: linear-gradient(160deg, var(--bg-3), var(--bg-2)); }
.card .noposter { display: grid; place-items: center; padding: 10px; color: var(--dim); text-align: center; font-size: 13px; }
.card .t { padding: 7px 9px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { padding: 0 9px 8px; font-size: 12px; color: var(--dim); }
.card .star { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .55); border-radius: 50%; }
.card .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .15); }
.card .bar > span { display: block; height: 100%; background: var(--red); }
.more { display: block; margin: 16px auto; }

.detail-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .8); display: flex; align-items: center; justify-content: center; padding: 16px; }
.detail { width: min(960px, 100%); max-height: 92vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; position: relative; }
.detail .close { position: absolute; top: 10px; right: 10px; }
.detail-head { display: flex; gap: 18px; padding: 20px; }
.detail-head img { width: 180px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--r); flex: none; background: var(--bg-3); }
.detail-head h2 { margin: 0 40px 6px 0; font-size: 22px; }
.detail-head .plot { margin: 10px 0; }
.detail-head .cast { font-size: 13px; color: var(--dim); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.seasons { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px; }
.seasons button.on { border-color: var(--accent); background: var(--accent-dim); }
.episodes { display: grid; gap: 6px; padding: 12px 20px 20px; }
.episode { display: flex; gap: 10px; align-items: center; text-align: left; }
.episode .t { flex: 1; min-width: 0; }
.episode.watched .t { color: var(--dim); }
.episode .d { color: var(--dim); font-size: 12px; white-space: nowrap; }
@media (max-width: 640px) { .detail-head { flex-direction: column; } .detail-head img { width: 140px; } }

/* Guide */
.guide { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 12px 16px; gap: 10px; }
.guide-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.guide-bar input { max-width: 280px; }
.g-scroll { flex: 1; overflow: auto; position: relative; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-2); }
.g-inner { position: relative; }
.g-head { position: sticky; top: 0; z-index: 3; display: flex; background: var(--bg-2); border-bottom: 1px solid var(--border); height: 32px; }
.g-corner { position: sticky; left: 0; z-index: 4; background: var(--bg-2); flex: none; border-right: 1px solid var(--border); }
.g-slot { flex: none; padding: 7px 8px; font-size: 12px; color: var(--dim); border-left: 1px solid var(--border); }
.g-slot.day { color: var(--accent); font-weight: 700; }
.g-body { position: relative; }
.g-row { position: absolute; left: 0; right: 0; display: flex; border-bottom: 1px solid var(--border); }
.g-ch { position: sticky; left: 0; z-index: 2; flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 0; border-right: 1px solid var(--border); border-radius: 0; background: var(--bg-2); text-align: left; overflow: hidden; }
.g-ch img { width: 32px; height: 32px; object-fit: contain; flex: none; }
.g-ch span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.g-track { position: relative; flex: none; }
.g-p { position: absolute; top: 4px; bottom: 4px; padding: 4px 8px; border-radius: 6px; text-align: left; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.g-p.now { border-color: var(--accent); background: var(--accent-dim); }
.g-p.past { opacity: .55; }
.g-p b, .g-p i { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: normal; }
.g-p b { font-size: 12.5px; }
.g-p i { font-size: 11px; color: var(--dim); }
.g-none { position: absolute; top: 18px; left: 10px; font-size: 12px; color: var(--dim); }
.g-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); box-shadow: 0 0 8px var(--red-glow); z-index: 1; pointer-events: none; }

/* A phone or a small tablet: the list slides over the player, the top bar in rows. */
@media (max-width: 760px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 15px; }
  .brand img { height: 34px; max-width: 140px; }
  .tabs { order: 8; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 6px 10px; white-space: nowrap; flex: 1; }
  .search-wrap { order: 9; max-width: none; flex-basis: 100%; min-width: 0; }
  .account { gap: 8px; font-size: 12px; }
  .account a { padding: 4px 6px; }
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 30; width: min(320px, 85vw); box-shadow: 8px 0 30px rgba(0, 0, 0, .6); transition: transform .2s; }
  .sidebar.collapsed { margin-left: 0; transform: translateX(-100%); box-shadow: none; }
  .ch .star { padding: 10px 6px; }
  .player-area { padding: 8px; gap: 8px; }
  .video-wrap { flex: 0 0 auto; aspect-ratio: 16 / 9; max-height: 100%; }
  .player-info { font-size: 13px; }
  .open-list { padding: 12px 5px; font-size: 12px; }
  .browse { padding: 10px; }
  .browse-bar input, .browse-bar select { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
  .card { width: 115px; }
  .card .t { font-size: 12px; padding: 6px 7px; }
  .detail-bg { padding: 0; }
  .detail { max-height: 100dvh; height: 100%; border-radius: 0; }
  .detail-head { padding: 14px; gap: 12px; }
  .detail-head h2 { font-size: 18px; }
  .seasons, .episodes { padding-left: 14px; padding-right: 14px; }
  .guide { padding: 8px; }
}
@media (max-width: 480px) {
  .account > span, .brand span { display: none; }
}
/* A phone on its side: the video takes the height. */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .topbar { padding: 4px 10px; }
  .tabs { order: 0; flex-basis: auto; }
  .search-wrap { order: 0; flex: 1 1 140px; }
  .video-wrap { aspect-ratio: auto; flex: 1; }
  .player-info { display: none; }
}
