@font-face { font-family: Saira; src: url(saira.ttf); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #151b28; --panel: #1a202e; --card: #212a3d; --line: #2c374f;
  --text: #eef2fb; --dim: #8e9ab8; --accent: #1272A5; --accent2: #25A5AE;
  --top: env(safe-area-inset-top); --bot: env(safe-area-inset-bottom);
  --left: env(safe-area-inset-left); --right: env(safe-area-inset-right);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px Saira, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column;
  padding: var(--top) var(--right) 0 var(--left); }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* abertura */
.splash { align-items: center; justify-content: center; gap: 28px; }
.splash img { width: min(70vw, 420px); }
.ring { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { color: var(--dim); font-size: 14px; text-align: center; padding: 0 24px; min-height: 20px; }

/* barra superior */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex: none; }
.bar h1 { font-size: 19px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 42px; height: 42px; border-radius: 12px; background: var(--panel); font-size: 22px; display: grid; place-items: center; flex: none; }
.icon:active, .tile:active, .card:active, .chip:active, .btn:active { filter: brightness(1.3); }

/* início */
.home { overflow-y: auto; padding: 8px 16px calc(24px + var(--bot)); }
.home .head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; }
.home .head img { height: 44px; }
.clock { font-size: 30px; font-weight: 300; letter-spacing: 1px; }
.big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.big .tile { height: 118px; }
.row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 10px 4px; text-align: center; font-weight: 600; font-size: 14px; }
.tile .em { font-size: 34px; line-height: 1; }
.big .tile { background: linear-gradient(160deg, #1f3a78, #16233f); font-size: 15px; }
.big .tile:nth-child(2) { background: linear-gradient(160deg, #6b2a8f, #261637); }
.big .tile:nth-child(3) { background: linear-gradient(160deg, #a14d17, #3a2113); }
.row .tile { font-size: 12px; font-weight: 500; }
.row .tile .em { font-size: 24px; }
.sub { color: var(--dim); font-size: 13px; text-align: center; margin-top: 18px; }

/* seções */
.sec { flex: 1; display: flex; min-height: 0; }
.side { width: 230px; flex: none; overflow-y: auto; background: var(--panel); padding: 6px 0; }
.side button { display: block; width: 100%; text-align: left; padding: 12px 16px; color: var(--dim); font-size: 15px; }
.side button.on { color: var(--text); background: var(--card); border-left: 3px solid var(--accent); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cats { display: none; overflow-x: auto; white-space: nowrap; padding: 4px 12px 8px; flex: none; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { display: inline-block; padding: 8px 14px; border-radius: 999px; background: var(--panel); color: var(--dim); margin-right: 8px; font-size: 14px; }
.chip.on { background: var(--accent); color: #fff; }
.letters { display: flex; overflow-x: auto; padding: 0 12px 8px; gap: 4px; flex: none; scrollbar-width: none; }
.letters::-webkit-scrollbar { display: none; }
.letters button { flex: none; white-space: nowrap; min-width: 32px; padding: 6px 8px; border-radius: 8px; color: var(--dim); font-size: 14px; }
.letters button.on { background: var(--accent2); color: #000; font-weight: 700; }
.grid { flex: 1; overflow-y: auto; padding: 4px 12px calc(20px + var(--bot)); display: grid; gap: 10px; align-content: start; -webkit-overflow-scrolling: touch; }
.grid.live { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid.poster { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.card { background: var(--card); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; position: relative; text-align: left; }
.card .art { background: #0e1424; position: relative; height: 0; overflow: hidden; }
.card .art > * { position: absolute; }
.live .card .art { padding-top: 62.5%; }
.live .card .art img { top: 8px; left: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; }
.poster .card .art { padding-top: 150%; }
.poster .card .art img { top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.art .ph { color: var(--dim); font-size: 12px; padding: 8px; text-align: center; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; }
.card .name { padding: 7px 9px 2px; font-size: 13px; font-weight: 600; line-height: 1.2; max-height: 2.5em; overflow: hidden; }
.card .now { padding: 0 9px 8px; font-size: 11.5px; color: var(--accent2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.4em; }
.poster .card .name { max-height: 3.7em; padding-bottom: 8px; }
.star { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.55); font-size: 16px; display: grid; place-items: center; color: #ccc; }
.star.on { color: #ffcc33; }
.empty { color: var(--dim); text-align: center; padding: 40px 20px; grid-column: 1 / -1; }
.more { grid-column: 1 / -1; height: 1px; }

/* formulários e listas */
.form { padding: 12px 16px calc(24px + var(--bot)); overflow-y: auto; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs .chip { flex: 1; text-align: center; margin: 0; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; color: var(--dim); font-size: 13px; margin-bottom: 4px; }
.field input, .field textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); font: inherit; }
.field textarea { min-height: 90px; }
.btn { display: block; width: 100%; background: var(--accent); color: #fff; padding: 14px; border-radius: 12px; font-weight: 600; text-align: center; margin-top: 6px; }
.btn.alt { background: var(--panel); border: 1px solid var(--line); }
.btn.danger { background: #5a1d28; }
.err { color: #ff7b8a; font-size: 14px; margin: 8px 0; min-height: 18px; }
.list { padding: 4px 12px; overflow-y: auto; flex: 1; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; width: 100%; text-align: left; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-size: 15px; }
.item .t small { color: var(--dim); }
.item.on { border: 1px solid var(--accent); }
.search { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text); }
.seasons { display: flex; gap: 8px; overflow-x: auto; padding: 4px 12px 10px; flex: none; }
.ep { display: flex; gap: 10px; align-items: baseline; }
.ep em { color: var(--accent2); font-style: normal; font-weight: 700; min-width: 34px; }

/* player */
#player { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: #000; z-index: 50; }
#player[hidden] { display: none; }
#video { width: 100%; height: 100%; background: #000; object-fit: contain; }
#ptop { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--top)) calc(12px + var(--right)) 24px calc(12px + var(--left));
  background: linear-gradient(#000c, #0000); transition: opacity .25s; }
#pbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 24px calc(12px + var(--right)) calc(12px + var(--bot)) calc(12px + var(--left)); background: linear-gradient(#0000, #000c); transition: opacity .25s; }
#player.idle #ptop, #player.idle #pbar { opacity: 0; pointer-events: none; }
#player button { min-width: 44px; height: 44px; border-radius: 22px; background: #ffffff26; padding: 0 12px; font-size: 18px; }
#pback { font-size: 30px; line-height: 1; padding-bottom: 4px; }
#ptitle { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#ptitle b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ptitle span { font-size: 13px; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pmsg { position: absolute; left: 20px; right: 20px; top: 50%; transform: translateY(-50%); text-align: center; background: #000b; padding: 14px; border-radius: 12px; }
#pmsg[hidden] { display: none; }
#pquality { font-size: 14px !important; }

/* celular */
@media (max-width: 599px) {
  .side { display: none; }
  .cats { display: block; }
  .tile .em { font-size: 28px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .home .head { margin-bottom: 8px; }
  .big .tile { height: 96px; }
}

/* convite para instalar */
#install { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--bot)); z-index: 40; background: #1f3a78; border-radius: 16px;
  padding: 14px 16px; box-shadow: 0 6px 24px #000a; display: flex; gap: 12px; align-items: flex-start; }
#install b { display: block; margin-bottom: 4px; }
#install span { font-size: 14px; color: #dbe6ff; line-height: 1.35; }
#install button { flex: none; width: 32px; height: 32px; border-radius: 16px; background: #ffffff26; font-size: 16px; }
#install .share { display: inline-block; border: 1.5px solid #fff; border-radius: 4px; padding: 0 5px; font-size: 13px; }

/* logos de canais inteiros, sem cortar */
.live .card .art .logo { top: 8px; left: 8px; right: 8px; bottom: 8px; background: center / contain no-repeat; }

/* player sempre na horizontal: com o celular em pé, a tela do player gira */


/* ativação */
.activate { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 6px; }
.activate img { width: min(60vw, 220px); }
.activate h2 { margin: 8px 0 14px; font-size: 30px; }
.activate .lbl { color: var(--dim); font-size: 15px; }
.activate .code { color: var(--accent2); font-size: clamp(44px, 16vw, 64px); font-weight: 700; letter-spacing: .12em; padding: 6px 0 10px; }
.activate p { max-width: 320px; margin: 0 0 22px; font-size: 17px; }
.activate .status { padding-top: 10px; }

/* séries e episódios em cartões 16:9 */
.poster.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.poster.wide .card .art { padding-top: 56.25%; }
.sub2 { padding: 0 9px 8px; font-size: 11px; color: var(--accent2); line-height: 1.25; max-height: 2.6em; overflow: hidden; }
.grid.eps { padding-top: 10px; }
/* senha 18+ e ajustes */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 24px; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(360px, 100%); }
.modal h3 { margin: 0 0 6px; } .modal p { margin: 0 0 12px; color: var(--dim); font-size: 14px; }
.modal input { width: 100%; text-align: center; font-size: 26px; letter-spacing: .3em; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); }
.modal .err { color: #ff7b8a; font-size: 13px; min-height: 18px; margin: 6px 0; text-align: center; }
.modal .acts { display: flex; gap: 10px; } .modal .acts .btn { margin: 0; }
.sh { margin: 8px 0 4px; font-size: 16px; } .hint { color: var(--dim); font-size: 14px; margin: 0 0 12px; }

/* celular em pé: o app inteiro gira 90° para ficar sempre na horizontal (o iPhone não deixa travar a orientação) */
html.rot body { position: fixed; top: 0; left: 0; width: var(--vw); height: var(--vh); overflow: hidden; transform-origin: 0 0; transform: translateX(var(--vh)) rotate(90deg);
  --top: 0px; --bot: 0px; --left: env(safe-area-inset-top); --right: env(safe-area-inset-bottom); }
html.rot #app, html.rot #player { position: absolute; }
