:root {
  --bg: #06070b;
  --bg-1: #0d0f16;
  --bg-2: #141722;
  --bg-3: #1b1f2c;
  --line: #262b3a;
  --text: #eef0f6;
  --dim: #a3a8b8;
  --muted: #6f7486;
  --brand: #7c5cff;
  --brand-2: #22d3c5;
  --danger: #ff5c7a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  font-size: 15px; line-height: 1.5; min-height: 100dvh;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px; background: rgba(6, 7, 11, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.top img { width: 34px; height: 34px; border-radius: 10px; }
.top h1 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.top .back { width: 38px; height: 38px; border-radius: 12px; background: var(--bg-2); font-size: 20px; }
main { padding: 12px 14px calc(84px + var(--safe-b)); max-width: 1400px; margin: 0 auto; }
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(13, 15, 22, .96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  color: var(--muted); text-decoration: none; font-size: 11.5px; border-radius: 14px;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--text); background: rgba(124, 92, 255, .16); }
.nav a.on svg { color: var(--brand); }

/* ---------------------------------------------------------------- pieces */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -14px; padding-inline: 14px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--dim); white-space: nowrap; font-size: 13.5px; scroll-snap-align: start;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.h2 { margin: 6px 2px 10px; font-size: 16px; font-weight: 700; }
.note { color: var(--muted); font-size: 13px; padding: 30px 8px; text-align: center; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.posters { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
@media (min-width: 700px) { .grid.posters { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.card {
  position: relative; display: block; width: 100%; text-align: start; border-radius: 14px; overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--line);
}
.card:active { transform: scale(.98); }
.card .art {
  aspect-ratio: 16 / 10; display: grid; place-items: center; background: linear-gradient(145deg, #22194a, #121521);
  font-size: 22px; font-weight: 800; color: rgba(255, 255, 255, .55); overflow: hidden;
}
.card .art img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.posters .card .art { aspect-ratio: 2 / 3; }
.posters .card .art img { object-fit: cover; padding: 0; }
.card .t { padding: 7px 9px 9px; font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.card .badge { position: absolute; top: 6px; inset-inline-start: 6px; padding: 1px 7px; border-radius: 6px; font-size: 10.5px; background: rgba(0, 0, 0, .65); color: #fff; }
.card .fav { position: absolute; top: 4px; inset-inline-end: 4px; width: 30px; height: 30px; border-radius: 9px; background: rgba(0, 0, 0, .55); color: #ffd34d; font-size: 15px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 14px; background: var(--bg-3); border: 1px solid var(--line); font-weight: 600;
}
.btn.brand { background: linear-gradient(135deg, #8a6bff, #5b3df5); border: 0; color: #fff; }
.btn.block { width: 100%; }
.panel { background: var(--bg-1); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row span:first-child { color: var(--dim); }
.switch { position: relative; width: 52px; height: 30px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--brand); border-color: var(--brand); }
.switch.on::after { transform: translateX(-22px); }
.search { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; font-size: 16px; }
.spinner { width: 28px; height: 28px; margin: 40px auto; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 18px calc(24px + var(--safe-b)); }
.login .box { width: 100%; max-width: 380px; }
.login .logo { width: 96px; height: 96px; border-radius: 26px; margin: 0 auto 14px; box-shadow: 0 10px 40px rgba(124, 92, 255, .35); }
.login h1 { text-align: center; margin: 0; font-size: 24px; }
.login p.sub { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13.5px; color: var(--dim); margin-bottom: 6px; }
.field input {
  width: 100%; height: 52px; padding: 0 14px; border-radius: 14px; background: var(--bg-3); border: 1px solid var(--line);
  outline: none; font-size: 16px; direction: ltr; text-align: left;
}
.field input:focus { border-color: var(--brand); }
.err { background: rgba(255, 92, 122, .1); border: 1px solid rgba(255, 92, 122, .3); color: var(--danger); padding: 10px 12px; border-radius: 12px; font-size: 13.5px; margin-bottom: 14px; }
.hint { margin-top: 18px; padding: 12px 14px; border-radius: 14px; background: var(--bg-1); border: 1px solid var(--line); font-size: 13px; color: var(--dim); line-height: 1.7; }

/* ---------------------------------------------------------------- show page */
.show-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.show-head img { width: 110px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 12px; background: var(--bg-2); flex: none; }
.show-head h2 { margin: 0 0 6px; font-size: 18px; }
.eps { display: flex; flex-direction: column; gap: 8px; }
.ep { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--bg-1); border: 1px solid var(--line); text-align: start; width: 100%; }
.ep b { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-3); flex: none; font-size: 13px; }
.ep span { flex: 1; font-size: 14px; }

/* ---------------------------------------------------------------- player */
#player { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
#player .bar {
  display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 10px 8px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0)); position: absolute; inset: 0 0 auto 0; z-index: 2;
}
#player .bar .title { flex: 1; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player .bar button { width: 42px; height: 42px; border-radius: 12px; background: rgba(255, 255, 255, .12); font-size: 18px; color: #fff; }
#player video { flex: 1; width: 100%; height: 100%; background: #000; }
#player .status { position: absolute; inset: auto 0 calc(90px + var(--safe-b)) 0; text-align: center; color: #fff; z-index: 2; pointer-events: none; }
#player .status .box { display: inline-block; max-width: 86%; padding: 10px 16px; border-radius: 14px; background: rgba(0, 0, 0, .7); font-size: 14px; pointer-events: auto; }
#player .status .box .btn { margin-top: 10px; }

/* ---------------------------------------------------------------- sheet / toast */
#sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .78); display: grid; place-items: center; padding: 20px; }
#sheet .box { width: 100%; max-width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 22px; padding: 22px; text-align: center; }
#sheet h3 { margin: 0 0 6px; font-size: 17px; }
#sheet p { margin: 0 0 16px; color: var(--dim); font-size: 13.5px; }
#sheet .btn { width: 100%; margin-top: 8px; }
#toast { position: fixed; z-index: 70; inset: auto 16px calc(90px + var(--safe-b)) 16px; text-align: center; }
#toast div { display: inline-block; padding: 10px 16px; border-radius: 14px; background: #222738; color: #fff; font-size: 14px; }

/* ---------------------------------------------------------------- install prompt */
#sheet .install .install-logo { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 12px; box-shadow: 0 8px 30px rgba(124, 92, 255, .35); }
#sheet .steps { text-align: start; margin: 0 0 14px; padding-inline-start: 22px; color: var(--text); font-size: 14px; line-height: 2; }
#sheet .steps b { color: #fff; }
#sheet .linkish { margin-top: 10px; color: var(--muted); font-size: 13px; text-decoration: underline; background: none; }

/* ---------------------------------------------------------------- iOS share-button arrow */
.a2hs { position: fixed; z-index: 80; display: flex; flex-direction: column; align-items: center; pointer-events: none; direction: ltr; }
.a2hs > * { pointer-events: auto; }
.a2hs.bottom-center { left: 50%; transform: translateX(-50%); bottom: calc(4px + var(--safe-b)); }
.a2hs.bottom-right { right: 6px; bottom: calc(4px + var(--safe-b)); align-items: flex-end; }
.a2hs.top-right { right: 6px; top: calc(2px + var(--safe-t)); align-items: flex-end; flex-direction: column-reverse; }
.a2hs-bubble {
  position: relative; width: min(300px, calc(100vw - 24px)); padding: 14px 14px 10px; border-radius: 18px;
  background: #fff; color: #111; box-shadow: 0 12px 40px rgba(0, 0, 0, .45); font-size: 14px; line-height: 1.8; direction: rtl;
}
.a2hs-bubble b { color: #000; }
.a2hs-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 15px; }
.a2hs-head img { width: 34px; height: 34px; border-radius: 10px; }
.a2hs-x { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 50%; background: #eee; color: #333; font-size: 13px; }
.a2hs-never { display: block; margin: 4px auto 0; background: none; color: #777; font-size: 12px; text-decoration: underline; }
.a2hs-arrow { font-size: 34px; line-height: 1; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); animation: a2hs-bounce 1s ease-in-out infinite; padding: 2px 10px; }
.a2hs.top-right .a2hs-arrow { animation-name: a2hs-bounce-up; }
@keyframes a2hs-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes a2hs-bounce-up { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------------------------------------------------------------- VLC required note */
.vlc-note { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: rgba(255, 136, 0, .1); border: 1px solid rgba(255, 136, 0, .35); font-size: 13px; line-height: 1.6; color: var(--dim); }
.vlc-note b { color: #ffb15c; }
.vlc-note img { width: 38px; height: 38px; flex: none; }
.vlc-note .btn { min-height: 38px; padding: 0 14px; flex: none; background: #ff8800; border: 0; color: #fff; font-size: 13px; text-decoration: none; }
.login-note { margin-top: 16px; }
.vlc-banner { position: relative; max-width: 1400px; margin: 10px auto 0; padding: 0 14px; }
.vlc-banner .vlc-note { padding-inline-end: 40px; }
.vlc-hide { position: absolute; top: 6px; left: 20px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 12px; }
.a2hs-step a { color: #ff7a00; font-weight: 700; }

/* ---------------------------------------------------------------- TV (Samsung / LG): remote-control layout */
.tv body { font-size: 19px; }
.tv main { padding: 18px 40px 110px; max-width: none; }
.tv .top { padding: 16px 40px; }
.tv .top img { width: 46px; height: 46px; }
.tv .top h1 { font-size: 24px; }
.tv .chips { margin: 0 -40px; padding: 4px 40px 18px; gap: 12px; }
.tv .chip { padding: 12px 22px; font-size: 18px; }
.tv .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tv .grid.posters { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tv .card .t { font-size: 17px; }
.tv .nav { padding: 8px 40px; }
.tv .nav a { font-size: 15px; }
.tv .nav a svg { width: 28px; height: 28px; }
.tv .ep { padding: 16px; }
.tv .ep span { font-size: 18px; }
.tv :focus { outline: none; }
.tv .card:focus, .tv .chip:focus, .tv .ep:focus, .tv .btn:focus, .tv .nav a:focus, .tv .switch:focus,
.tv .search input:focus, .tv .field input:focus, .tv #player .bar button:focus, .tv .back:focus {
  outline: 4px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 8px rgba(124, 92, 255, .55);
}
.tv .card:focus { transform: scale(1.05); z-index: 1; transition: transform .12s; }
.tv-hint {
  position: absolute; inset: auto 0 34px 0; margin: auto; width: max-content; max-width: 90%; padding: 10px 22px;
  border-radius: 999px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 18px; transition: opacity .6s; z-index: 2;
}
.tv-hint.gone { opacity: 0; }
