:root {
  --bg: #16181d;
  --panel: #1f2229;
  --bar: #1f2229;
  --text: #ffffff;
  --muted: #a4a9b5;
  --accent: #f2a93b;
  --primary: #f2a93b;
  --active: #323743;
  --ok: #2fbf71;
  --bad: #e5484d;
  --gold: #ffc94d;
  --row: 58px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Ubuntu, Cantarell, "Noto Sans", Roboto, sans-serif;
  font-size: 15px;
  overflow: hidden;
  user-select: none;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#screen { height: 100%; }

/* ---------- pantallas de inicio ---------- */
.page { height: 100%; overflow: auto; display: flex; justify-content: center; align-items: flex-start; }
.column { width: min(560px, 100% - 32px); display: flex; flex-direction: column; align-items: center; padding: 48px 0 32px; margin: auto 0; }
.emblem { width: 260px; height: 65px; }
.emblem.small { width: 180px; height: 45px; }
h1 { font-size: 26px; margin: 18px 0 6px; font-weight: 700; text-align: center; }
.help { color: var(--muted); text-align: center; margin: 6px 0 0; line-height: 1.45; white-space: pre-line; }
.msg { font-size: 17px; text-align: center; margin: 20px 0 0; line-height: 1.45; white-space: pre-line; }
.ok-text { color: var(--ok); margin-top: 12px; }

.device-box { width: 100%; background: var(--panel); border-radius: 14px; padding: 14px 20px; margin-top: 22px; text-align: center; border: 1px solid #323743; }
.device-box .label { color: var(--muted); font-size: 14px; margin-top: 6px; }
.device-box .value { font-family: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-weight: 700; font-size: 28px; letter-spacing: 1px; user-select: text; }
.device-box.big .value { font-size: 36px; }

.btn {
  background: var(--active);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 9px 20px;
  min-height: 44px;
  cursor: pointer;
  font-size: 15px;
  margin-top: 12px;
}
.btn:hover { background: #3a3f4b; }
.btn:focus-visible, .btn:focus { outline: none; border-color: var(--accent); background: var(--primary); }
.btn.primary { background: var(--primary); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.wide { width: 100%; text-align: left; }
/* 4.9: interruptor «VPN» de Ajustes */
.btn.switch::after { content: ''; display: inline-block; width: 30px; height: 16px; border-radius: 8px; margin-left: 10px; vertical-align: -2px; background: #5a5f6b radial-gradient(circle at 8px 8px, #fff 5px, transparent 6px); }
.btn.switch.on::after { background: #3fa66a radial-gradient(circle at 22px 8px, #fff 5px, transparent 6px); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

input.text {
  width: 100%;
  background: var(--panel);
  border: 2px solid #323743;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 20px;
  user-select: text;
}
input.text:focus { outline: none; border-color: var(--accent); }

.spinner { width: 46px; height: 46px; border: 4px solid #323743; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin-top: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- navegador ---------- */
.browser { height: 100%; display: flex; flex-direction: column; padding: 10px 16px 8px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .logo { width: 32px; height: 32px; object-fit: contain; }
/* Dentro de la app, el nombre completo; el icono instalado sigue siendo solo la Z. */
.topbar .logo.wordmark { width: 105px; height: 26px; }
.tabs { display: flex; gap: 6px; }
.tab { background: transparent; border: 1px solid transparent; border-radius: 20px; padding: 0 16px; height: 40px; cursor: pointer; font-size: 15px; white-space: nowrap; }
.tab:hover { background: #2b2f38; }
.tab.active { background: #3a3f4b; border-color: var(--accent); }
.tab:focus-visible { outline: none; border: 3px solid var(--accent); background: var(--primary); }
.search { flex: 1; min-width: 120px; height: 40px; background: var(--panel); border: 2px solid #323743; border-radius: 20px; padding: 0 16px; user-select: text; }
.search:focus { outline: none; border-color: var(--accent); }
.chip { font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 14px; white-space: nowrap; }
.chip.ok { background: #14532d; color: #b8f5cf; }
.chip.bad { background: #5c1a1d; color: #ffc9cb; }
.chip.neutral { background: #343844; color: #d6d9df; }
.topbar .btn { margin: 0; min-height: 40px; padding: 0 14px; }

.body { flex: 1; display: flex; gap: 14px; min-height: 0; margin-top: 10px; }
.cats { width: 32%; max-width: 380px; min-width: 220px; background: var(--panel); border-radius: 12px; padding: 6px; overflow-y: auto; }
.cat { padding: 11px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
.cat:hover { background: #2b2f38; }
.cat.active { background: var(--active); border-color: var(--accent); }
.cat.focus { background: var(--primary); }
.right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.right-head { color: var(--accent); font-weight: 700; font-size: 16px; padding: 0 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 10px; align-items: center; }
.right-head .back { color: var(--text); font-weight: 400; cursor: pointer; background: var(--active); border-radius: 8px; padding: 2px 10px; font-size: 14px; }
.list-box { flex: 1; position: relative; min-height: 0; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 16px; text-align: center; white-space: pre-line; pointer-events: none; padding: 20px; }

/* lista virtual: solo se pintan las filas visibles */
.vlist { position: absolute; inset: 0; overflow-y: auto; outline: none; }
.vlist .spacer { position: relative; width: 100%; }
.row { position: absolute; left: 0; right: 4px; height: calc(var(--row) - 4px); display: flex; align-items: center; padding: 4px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.row:hover { background: #2b2f38; }
.row.sel { background: var(--active); border-color: var(--accent); }
.vlist:focus .row.sel { background: var(--primary); }
.row img { width: 64px; height: 42px; object-fit: contain; flex: none; }
.row .num { min-width: 52px; text-align: right; color: var(--muted); font-size: 14px; margin-left: 4px; }
.row .name { flex: 1; margin-left: 12px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .marks { color: var(--gold); margin-left: 8px; white-space: nowrap; }
.row .more { visibility: hidden; margin-left: 8px; background: transparent; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 6px; }
.row:hover .more, .row.sel .more { visibility: visible; }

/* cuadrícula de botones (como en Android): carátula o logo y el nombre en pequeño debajo */
.tile { position: absolute; display: flex; flex-direction: column; padding: 6px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; background: #282c35; }
.tile:hover { background: #2b2f38; }
.tile.sel { background: var(--active); border-color: var(--accent); }
.vlist:focus .tile.sel { background: var(--primary); }
.tile .pic { position: relative; flex: 1; min-height: 0; border-radius: 6px; overflow: hidden; background: #1b1d23; }
.tile .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .pic img.cover { object-fit: cover; }
.tile .num, .tile .marks { position: absolute; top: 4px; font-size: 12px; font-weight: 700; background: rgba(0, 0, 0, .7); border-radius: 4px; padding: 1px 5px; }
.tile .num { left: 4px; color: var(--text); }
.tile .marks { right: 4px; color: var(--gold); }
.tile .more { position: absolute; right: 4px; bottom: 4px; visibility: hidden; background: rgba(0, 0, 0, .7); border: 0; border-radius: 4px; color: var(--text); font-size: 16px; cursor: pointer; padding: 0 6px; }
.tile:hover .more, .tile.sel .more { visibility: visible; }
.tile .name { flex: none; height: 34px; margin-top: 6px; font-size: 13px; line-height: 17px; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
/* capítulos (4.8): «●» los que no se han visto, casillas al seleccionar varios, barra de la selección */
.dot { color: #F2A93B; font-size: .8em; margin-right: 6px; }
.check { color: var(--text); margin-right: 6px; }
.vlist:focus .row.sel .dot, .vlist:focus .tile.sel .dot, .vlist:focus .row.sel .check, .vlist:focus .tile.sel .check { color: #1f2229; }
.right-head .btn { margin: 0; min-height: 32px; padding: 0 14px; font-size: 14px; }

/* ---------- menús y avisos ---------- */
.menu { position: fixed; z-index: 50; background: #242830; border: 1px solid #3a3f4b; border-radius: 10px; padding: 6px; min-width: 260px; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.menu .title { color: var(--accent); font-weight: 700; padding: 8px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .opt { padding: 10px 12px; border-radius: 7px; cursor: pointer; }
.menu .opt:hover, .menu .opt.focus { background: var(--primary); }
#modal { position: fixed; inset: 0; z-index: 60; background: rgba(18,20,24, .7); display: flex; align-items: center; justify-content: center; }
.dialog { background: var(--panel); border: 1px solid #3a3f4b; border-radius: 14px; padding: 22px 24px; width: min(520px, 100% - 32px); }
.dialog h2 { margin: 0 0 12px; font-size: 20px; }
.dialog .rows { line-height: 1.7; user-select: text; white-space: pre-line; }
.dialog .btn-row { justify-content: flex-end; margin-top: 10px; }
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 70; background: #323743; border: 1px solid #3a3f4b; border-radius: 10px; padding: 12px 20px; max-width: 80%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* ---------- reproductor ---------- */
#player { position: fixed; inset: 0; background: #000; z-index: 40; overflow: hidden; }
#player.hide-cursor { cursor: none; }
#video { width: 100%; height: 100%; object-fit: contain; background: #000; }
#video.fill { object-fit: cover; }
#video.stretch { object-fit: fill; }
#player .spinner { position: absolute; left: 50%; top: 50%; margin: -23px 0 0 -23px; }
#p-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(31,34,41,.92); border-radius: 12px; padding: 18px 24px; max-width: 70%; text-align: center; font-size: 17px; line-height: 1.45; white-space: pre-line; }
#p-message .btn { margin: 14px 6px 0; }
#p-flash { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); background: rgba(31,34,41,.88); border-radius: 10px; padding: 10px 18px; font-size: 16px; max-width: 80%; text-align: center; }
#p-digits { position: absolute; right: 40px; top: 30px; font-size: 54px; font-weight: 700; text-shadow: 0 2px 8px #000; }
#p-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 32px 22px; background: linear-gradient(transparent, rgba(0,0,0,.85)); transition: opacity .25s; }
#p-overlay.hidden, #p-exit.hidden { opacity: 0; pointer-events: none; }
#p-exit { position: absolute; top: 18px; right: 22px; margin: 0; background: rgba(50,55,67,.85); transition: opacity .25s; z-index: 2; }
#p-exit:hover { background: var(--primary); }
#p-title { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#p-subtitle { color: #d6d9df; font-size: 16px; margin-top: 2px; }
.p-bar { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 14px; }
.p-bar span { min-width: 56px; }
.p-bar span:last-child { text-align: right; }
#p-seek { flex: 1; accent-color: var(--accent); height: 22px; cursor: pointer; }
#p-seek:disabled { cursor: default; opacity: .6; }
.p-buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.p-buttons .btn { margin: 0; min-height: 40px; padding: 0 14px; background: rgba(50,55,67,.85); }
.p-buttons .btn:hover, .p-buttons .btn:focus { background: var(--primary); }
.p-buttons .spacer { flex: 1; }
.p-buttons input[type=range] { width: 100px; accent-color: var(--accent); }
/* lista de canales: semitransparente, el canal que se está viendo sigue a la vista detrás */
#p-panel { position: absolute; left: 0; top: 0; bottom: 0; width: min(62%, 700px); background: linear-gradient(to right, rgba(31,34,41,.85), rgba(31,34,41,.6)); border-right: 1px solid rgba(242,169,59,.3); border-radius: 0 18px 18px 0; padding: 16px; display: flex; flex-direction: column; }
#p-panel-title { color: var(--accent); font-size: 18px; padding: 0 0 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-panel-lists { flex: 1; display: flex; gap: 10px; min-height: 0; }
.plist { width: 40%; overflow-y: auto; }
#p-panel-items { position: relative; flex: 1; }
#p-panel .vlist { position: relative; inset: auto; height: 100%; }
video::cue { background: rgba(0,0,0,.6); font-size: 1.1em; }

/* menú del reproductor: esquina izquierda, semitransparente, con los colores de la app */
#p-menu { background: rgba(31,34,41, 0.78); border: 1px solid rgba(242,169,59, 0.4); backdrop-filter: blur(6px); border-radius: 12px; min-width: 280px; }
#p-menu .title { color: var(--accent); font-weight: 700; }
#p-menu .opt { border-radius: 8px; }

/* ---------- pantalla de inicio (como la de HotPlayer) ---------- */
/* Todo en em: home() ajusta el tamaño de letra de .home al alto y ancho de la ventana para que quepa entera. */
.home { height: 100%; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.2em 1.2em; text-align: center; font-size: 16px;
  background: radial-gradient(ellipse at 50% 8%, #2b2f3a 0%, #1b1d23 45%, #121418 100%); }
.home-brand { position: relative; padding: 1em 2.9em 0; }
.home-brand img { width: 18.75em; height: 4.69em; display: block; }
.home-brand .ver { position: absolute; top: 0; right: 0; font-size: 0.85em; font-weight: 700; color: #f2a93b; }
.home-list { margin-top: 0.9em; font-size: 1.3em; color: #fff; cursor: pointer; }
.home-list b { color: #f2a93b; }
.home-pill { margin-top: 0.6em; background: #000; border: 1px solid #3e4350; border-radius: 2em; padding: 0.4em 1.2em; font-size: 1.1em; color: #fff; display: inline-block; }
.home-pill span + span { margin-left: 1.5em; }
.home-tiles { display: flex; justify-content: center; margin-top: 1.3em; width: 100%; max-width: 50em; }
/* Botones redondos: al elegirlos se llenan con el degradado del logo. */
.home-tile { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; background: none; border: 0; padding: 0.3em 0; color: #fff; font-family: inherit; font-size: 1em; cursor: pointer; outline: none; }
.home-circle { width: 9.5em; height: 9.5em; border-radius: 50%; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #323743, #282c35); border: 2px solid #3e4350; transition: transform 0.15s; }
.home-label { margin-top: 0.6em; font-size: 1.2em; font-weight: 700; white-space: nowrap; }
.home-tile:hover .home-circle, .home-tile:focus .home-circle { background: linear-gradient(135deg, #f7c26f, #f2a93b 50%, #e0922a); border: 3px solid #fff; transform: scale(1.06); box-shadow: 0 0 1.6em rgba(242,169,59,.45); }
.home-tile:focus .home-label { color: #f2a93b; }
.home-icon { width: 4em; height: 4em; }
.home-row { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 1.3em; }
.home-row .btn { margin: 0.25em 0.45em; font-size: 0.95em; padding: 0.55em 1.3em; border-radius: 2em; }
.home-mac { margin-top: 1.1em; font-size: 1em; font-weight: 700; color: #fff; }
.home-note { margin-top: 0.3em; font-size: 0.85em; color: #a4a9b5; }
.sections { display: flex; gap: 6px; margin-left: 10px; align-items: center; }
.tab.sec { color: #c9ccd3; }
.tab.sec.active { color: #fff; font-weight: 700; }
.tab.back { background: #323743; border-color: #3e4350; }
.tab.back:hover, .tab.back:focus { background: #f2a93b; border-color: var(--accent); outline: none; }

/* 4.1: paleta gris y naranja. Sobre el naranja el texto va en gris oscuro. */
.btn:focus-visible, .btn:focus, .btn.primary, .tab:focus-visible, .cat.focus, .vlist:focus .row.sel, .vlist:focus .row.sel .name,
.vlist:focus .row.sel .num, .vlist:focus .row.sel .more, .vlist:focus .tile.sel .name, .menu .opt:hover, .menu .opt.focus, #p-exit:hover,
.p-buttons .btn:hover, .tab.back:hover, .tab.back:focus { color: #1f2229; }
.home-tile:hover .home-icon, .home-tile:focus .home-icon { filter: brightness(0) opacity(0.85); }
/* 5.0: perfiles («¿Quién va a ver?», PIN y edición). Sin gap ni inset: las TV de 2018 no los tienen. */
.column.wide-col { width: 1000px; max-width: calc(100% - 32px); }
.ptiles { display: flex; flex-wrap: wrap; justify-content: center; margin: 1.2em 0 1.4em; max-width: 60em; }
.ptile { position: relative; display: flex; flex-direction: column; align-items: center; margin: 0.6em 0.8em; padding: 0.7em; width: 8.5em; background: none; border: 0.18em solid transparent; border-radius: 1em; color: #ddd; font: inherit; cursor: pointer; outline: none; }
.ptile:hover, .ptile:focus { border-color: #f2a93b; color: #fff; background: rgba(255, 255, 255, 0.06); }
.ptile .pname { margin-top: 0.55em; font-size: 1.15em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptile .plock { position: absolute; top: 0.5em; right: 0.6em; font-size: 0.95em; }
.ptile .pedit { position: absolute; top: 2.3em; left: 0; right: 0; text-align: center; font-size: 2.2em; color: #fff; text-shadow: 0 0 0.3em #000; }
.ptile.editing .pavatar { opacity: 0.55; }
.pavatar { display: flex; align-items: center; justify-content: center; width: 3.6em; height: 3.6em; border-radius: 0.7em; color: #fff; font-size: 1.6em; font-weight: 700; }
.pavatar.small { display: inline-flex; width: 1.6em; height: 1.6em; border-radius: 0.4em; font-size: 0.85em; margin-right: 0.5em; vertical-align: middle; }
.pavatar.add { background: transparent; border: 0.1em dashed #888; color: #bbb; }
.c0 { background: #f28c28; } .c1 { background: #3b82f6; } .c2 { background: #22a06b; } .c3 { background: #e5487f; }
.c4 { background: #8b5cf6; } .c5 { background: #d9a400; } .c6 { background: #14b8a6; } .c7 { background: #6b7280; }
.profile-btn { display: inline-flex; align-items: center; }
.pin-dots { display: flex; justify-content: center; margin: 0.8em 0 0.4em; }
.pin-dot { width: 1em; height: 1em; margin: 0 0.45em; border-radius: 50%; border: 0.12em solid #ccc; }
.pin-dot.on { background: #f2a93b; border-color: #f2a93b; }
.pin-note.bad { color: #ff7b6b; }
.pin-pad { display: flex; flex-wrap: wrap; justify-content: center; width: 15em; margin: 0.6em auto 0; }
.pin-pad .pin-key { width: 4.2em; margin: 0.3em; padding: 0.6em 0; font-size: 1.15em; }
.pform { display: flex; flex-direction: column; align-items: stretch; width: 28em; max-width: 100%; margin: 1em auto 1.2em; }
.pform > * { margin: 0.35em 0; }
.pswatches { display: flex; flex-wrap: wrap; justify-content: center; }
.pswatch { width: 2.4em; height: 2.4em; margin: 0.3em; border-radius: 0.5em; border: 0.18em solid transparent; cursor: pointer; outline: none; }
.pswatch.sel { border-color: #fff; box-shadow: 0 0 0 0.12em #000 inset; }
.pswatch:focus { border-color: #f2a93b; }
.btn.danger { color: #ff8a7a; }

/* ---------- 5.2.17: fichas (sinopsis, género, edad recomendada) ---------- */
.dialog.details-dialog { width: min(820px, 100% - 32px); }
.details { display: flex; align-items: flex-start; margin-bottom: 8px; }
.details .d-poster { width: 180px; height: 270px; object-fit: cover; border-radius: 10px; background: var(--active); flex: none; margin-right: 22px; }
.d-text { flex: 1; min-width: 0; }
.d-meta { display: flex; flex-wrap: wrap; align-items: center; color: var(--muted); margin-bottom: 10px; }
.d-meta > * { margin: 0 14px 4px 0; }
.d-age { border: 2px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 1px 8px; font-weight: 700; }
.d-age.all { border-color: var(--ok); color: var(--ok); }
.d-age.adult { border-color: var(--bad); color: #ff8a8d; }
.d-rating { color: var(--gold); font-weight: 700; }
.d-plot { line-height: 1.5; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 9; overflow: hidden; user-select: text; }
.d-plot.muted { color: var(--muted); }
.series-info { display: flex; align-items: flex-start; padding: 2px 8px 12px; }
.series-info .d-poster { width: 64px; height: 96px; object-fit: cover; border-radius: 8px; background: var(--active); flex: none; margin-right: 16px; }
.series-info .d-meta { margin-bottom: 6px; }
.series-info .d-plot { -webkit-line-clamp: 3; font-size: .95em; }

/* 5.3: entrar con usuario y contraseña */
.login-form { display: flex; flex-direction: column; gap: 12px; width: min(520px, 90vw); }
.login-form input.text { width: 100%; box-sizing: border-box; }
.login-msg { min-height: 1.4em; color: var(--accent); }
/* 5.3: activar la TV con un código desde el móvil */
.pair { display: flex; gap: 40px; align-items: center; justify-content: center; margin: 18px 0; }
.pair-qr { flex: 0 0 230px; width: 230px; height: 230px; background: #fff; border-radius: 12px; padding: 8px; box-sizing: border-box; }
.pair-qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.pair-text { text-align: left; max-width: 560px; }
.pair-text .help { text-align: left; }
.pair-page { font-size: 1.5em; font-weight: 700; margin: 4px 0 10px; word-break: break-all; }
.pair-code { font-size: 3.2em; font-weight: 800; letter-spacing: 0.12em; color: var(--accent); margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.pair-input { text-transform: uppercase; letter-spacing: 0.15em; font-size: 1.4em; text-align: center; }
