:root {
  --bg: #0D1017; --side: #141923; --card: #1D2431; --card2: #283044; --accent: #FFD400;
  --text: #F2F4F8; --muted: #9AA4B5; --dark: #12161F; --line: #374054;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
#app { height: 100%; }
.screen { position: absolute; inset: 0; overflow: auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 52px; height: 52px; }
.brand .word { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.word b { color: var(--accent); font-weight: 800; }

/* Foco (teclado y mouse) */
.f { outline: none; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.f:focus-visible, .f.kb:focus { box-shadow: 0 0 0 4px var(--accent); }

/* Botones */
.btn { background: var(--card); border: 0; border-radius: 12px; padding: 12px 22px; font-size: 17px; cursor: pointer; }
.btn:hover, .btn:focus { background: var(--accent); color: var(--dark); }
.btn.primary { background: var(--accent); color: var(--dark); font-weight: 700; }
.btn.small { padding: 8px 14px; font-size: 15px; border-radius: 10px; }

/* Inicio de sesión */
.login { display: flex; align-items: center; justify-content: center; background: linear-gradient(#101420, #05070C); }
.login form { width: min(420px, 92vw); background: var(--side); padding: 34px; border-radius: 22px; display: flex; flex-direction: column; gap: 14px; }
.login h2 { margin: 6px 0 0; font-size: 22px; }
.login input { background: var(--card); border: 2px solid transparent; border-radius: 12px; padding: 13px 14px; font-size: 17px; }
.login input:focus { border-color: var(--accent); outline: none; }
.login .err { color: #ff7b7b; min-height: 20px; font-size: 15px; }

/* Inicio */
.home { background: radial-gradient(ellipse at 50% 55%, #2a2410 0%, #15151A 45%, #06080E 100%); display: flex; flex-direction: column; }
.home header { display: flex; justify-content: space-between; align-items: flex-start; padding: 28px 42px 0; }
.home .clock { font-size: 15px; color: var(--muted); margin-top: 2px; }
.topright { display: flex; gap: 26px; }
.roundbtn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; cursor: pointer; }
.roundbtn .circle { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--card); font-size: 28px; font-weight: 800; color: #fff; transition: transform .15s, box-shadow .15s; }
.roundbtn .circle img { width: 60px; height: 60px; }
.roundbtn span { font-size: 13px; color: var(--muted); max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roundbtn:hover .circle, .roundbtn:focus .circle { transform: scale(1.1); box-shadow: 0 0 0 4px var(--accent); }
.roundbtn:focus { outline: none; }
.cards { flex: 1; display: flex; align-items: center; justify-content: center; gap: 36px; padding: 20px; }
.homecard { width: min(28vw, 380px); aspect-ratio: 236/262; border-radius: 22px; border: 1px solid var(--line);
  background: linear-gradient(#1E2432, #12161F); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer; padding: 12px; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.homecard img { width: 66%; aspect-ratio: 1; object-fit: contain; }
.homecard h3 { margin: 0; font-size: clamp(20px, 2.2vw, 32px); }
.homecard p { margin: 0; color: var(--muted); font-size: clamp(12px, 1vw, 15px); text-align: center; }
.homecard:hover, .homecard:focus { transform: scale(1.05); border: 4px solid var(--accent); background: linear-gradient(#283044, #12161F); outline: none; }
.hint { white-space: pre; text-align: center; color: #6E788C; font-size: 15px; padding: 0 0 22px; }

/* Usuarios */
.profiles { background: linear-gradient(#101420, #05070C); display: flex; flex-direction: column; }
.profiles .center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px; }
.profiles h1 { margin: 0; font-size: clamp(28px, 3vw, 44px); }
.plist { display: flex; gap: 36px; flex-wrap: wrap; justify-content: center; }
.pcell { display: flex; flex-direction: column; align-items: center; gap: 14px; background: none; border: 0; cursor: pointer; }
.pcell .av { width: 130px; height: 130px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 800; color: #fff; transition: transform .15s, box-shadow .15s; }
.pcell .av.add { background: var(--card); border: 2px solid #505A6E; color: var(--muted); font-weight: 300; font-size: 64px; }
.pcell span { color: var(--muted); font-size: 19px; }
.pcell:hover .av, .pcell:focus .av { transform: scale(1.08); box-shadow: 0 0 0 5px var(--accent); }
.pcell:hover span, .pcell:focus span { color: var(--text); font-weight: 700; }
.pcell:focus { outline: none; }

/* Secciones */
.section { display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; background: #10141E; display: flex; align-items: center; gap: 18px; padding: 14px 28px; }
.topbar .back { background: none; border: 0; color: var(--muted); font-size: 19px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.topbar .back:hover, .topbar .back:focus { background: var(--accent); color: var(--dark); outline: none; }
.topbar .brand img { width: 38px; height: 38px; }
.topbar .brand .word { font-size: 26px; }
.topbar h2 { margin: 0 0 0 10px; font-size: 26px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { background: var(--card); border: 2px solid transparent; border-radius: 22px; padding: 10px 18px; width: min(360px, 30vw); font-size: 16px; }
.search:focus { border-color: var(--accent); outline: none; }
.topbar .roundbtn .circle { width: 46px; height: 46px; font-size: 21px; }
.topbar .roundbtn .circle img { width: 42px; height: 42px; }
.topbar .roundbtn span { display: none; }
.chips { display: flex; gap: 10px; padding: 18px 28px 8px; overflow-x: auto; scrollbar-width: none; }
.chip { background: var(--card); border: 0; border-radius: 22px; padding: 10px 18px; white-space: nowrap; font-size: 16px; cursor: pointer; }
.chip.sel { background: #2A3344; box-shadow: inset 0 0 0 2px var(--accent); }
.chip:hover, .chip:focus { background: var(--accent); color: var(--dark); outline: none; }
.status { text-align: center; color: var(--muted); font-size: 19px; padding: 60px 20px; white-space: pre-line; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 24px 20px; padding: 14px 28px 50px; }
.grid.live { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: none; border: 0; padding: 6px; border-radius: 14px; text-align: left; cursor: pointer; min-width: 0; }
.card .poster { position: relative; aspect-ratio: 1 / 1.15; border-radius: 10px; overflow: hidden; background: var(--card); }
.grid.live .card .poster { aspect-ratio: 16 / 9; }
.card .poster img { width: 100%; height: 100%; object-fit: cover; }
.grid.live .card .poster img { object-fit: contain; padding: 10px; }
.card .poster .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 800; font-size: 20px; padding: 10px; }
.card .heart { position: absolute; top: 7px; right: 7px; width: 30px; height: 30px; border-radius: 15px; background: rgba(0,0,0,.8);
  color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.card .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(0,0,0,.6); }
.card .bar i { display: block; height: 100%; background: var(--accent); }
.card .t { margin-top: 8px; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover .poster, .card:focus .poster { box-shadow: 0 0 0 4px var(--accent); }
.card:focus { outline: none; }
.sentinel { height: 2px; }

/* Ficha */
.detail { display: flex; gap: 40px; padding: 30px 48px; }
.detail .poster { width: 260px; flex: none; aspect-ratio: 2/3; border-radius: 14px; object-fit: cover; background: var(--card); }
.detail .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.detail h1 { margin: 0; font-size: 34px; }
.detail .meta { color: var(--accent); margin: 8px 0 12px; font-size: 17px; }
.detail .desc { color: var(--muted); line-height: 1.5; max-height: 7.5em; overflow: auto; margin-bottom: 14px; }
.actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.eps { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 6px; }
.ep { background: var(--card); border: 0; border-radius: 10px; padding: 13px 18px; text-align: left; font-size: 17px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep:hover, .ep:focus { background: var(--accent); color: var(--dark); outline: none; }
.ep em { font-style: normal; color: var(--accent); }
.ep:hover em, .ep:focus em { color: var(--dark); }

/* Configuración */
.settings { padding: 14px 28px 60px; display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.row { background: var(--card); border: 0; border-radius: 12px; padding: 15px 22px; text-align: left; cursor: pointer; }
.row b { display: block; font-size: 19px; }
.row span { color: var(--muted); font-size: 15px; }
.row:hover, .row:focus { background: var(--accent); color: var(--dark); outline: none; }
.row:hover span, .row:focus span { color: var(--dark); }

/* Diálogos */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #1A202C; border-radius: 18px; padding: 26px; width: min(520px, 94vw); max-height: 88vh; overflow: auto;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal h3 { margin: 0 0 4px; font-size: 22px; }
.modal p { margin: 0; color: var(--muted); white-space: pre-line; }
.modal input { background: var(--card); border: 2px solid transparent; border-radius: 10px; padding: 12px; font-size: 16px; width: 100%; }
.modal input:focus { border-color: var(--accent); outline: none; }
.modal .opts { display: flex; flex-direction: column; gap: 6px; }
.modal .opts .btn { text-align: left; }
.modal .opts .btn.on { box-shadow: inset 0 0 0 2px var(--accent); }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; }
.colors button.on, .colors button:focus, .colors button:hover { box-shadow: 0 0 0 4px var(--accent); outline: none; }

#toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #222a3a; color: var(--text); padding: 12px 22px;
  border-radius: 12px; font-size: 16px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

/* Reproductor */
.player { position: fixed; inset: 0; background: #000; z-index: 30; overflow: hidden; cursor: default; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.player .subs { position: absolute; left: 6%; right: 6%; bottom: 7%; text-align: center; color: #fff; font-weight: 600;
  text-shadow: 0 0 6px #000, 0 0 3px #000, 0 0 10px #000; white-space: pre-line; pointer-events: none; transition: bottom .2s; }
.player.ui .subs { bottom: 19%; }
.player .spin { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border: 5px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player .msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.85); padding: 24px 30px;
  border-radius: 14px; text-align: center; font-size: 19px; display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 80vw; }
.player .osd { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 40px 26px; background: linear-gradient(transparent, rgba(0,0,0,.9));
  opacity: 0; transition: opacity .25s; }
.player.ui .osd, .player.ui .ptop { opacity: 1; }
.player .ptop { position: absolute; left: 0; right: 0; top: 0; padding: 20px 30px 50px; background: linear-gradient(rgba(0,0,0,.8), transparent);
  opacity: 0; transition: opacity .25s; display: flex; align-items: center; gap: 16px; }
.player .ptop h3 { margin: 0; font-size: 22px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .live-badge { color: #ff5a5a; font-weight: 800; }
.player .ctrls { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.player .ctrls .btn { background: rgba(255,255,255,.12); }
.player .ctrls .btn:hover, .player .ctrls .btn:focus { background: var(--accent); color: var(--dark); }
.player .time { color: var(--accent); font-size: 16px; min-width: 150px; }
.player input[type=range] { width: 100%; accent-color: var(--accent); }
.player .spacer { flex: 1; }
.chpanel { position: absolute; left: 0; top: 0; bottom: 0; width: 420px; max-width: 90vw; padding: 22px 18px 14px 26px;
  background: linear-gradient(90deg, rgba(10,13,20,.97) 0, rgba(10,13,20,.97) 85%, rgba(10,13,20,.85)); display: flex; flex-direction: column; z-index: 3; }
.chpanel .src { color: var(--accent); font-weight: 700; margin-top: 10px; }
.chpanel .list { flex: 1; overflow-y: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; padding-right: 6px; }
.chrow { display: flex; align-items: center; gap: 12px; background: none; border: 0; border-radius: 10px; padding: 8px 10px; text-align: left; cursor: pointer; }
.chrow .n { width: 30px; text-align: right; color: var(--muted); font-weight: 700; }
.chrow .lg { width: 54px; height: 32px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; overflow: hidden; background: var(--card); }
.chrow .lg img { width: 100%; height: 100%; object-fit: contain; }
.chrow .tx { flex: 1; min-width: 0; }
.chrow .tx b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chrow .tx small { color: var(--muted); }
.chrow .pl { color: var(--accent); visibility: hidden; }
.chrow.cur .pl { visibility: visible; }
.chrow:hover, .chrow:focus { background: var(--accent); color: var(--dark); outline: none; }
.chrow:hover .n, .chrow:focus .n, .chrow:hover small, .chrow:focus small, .chrow:hover .pl, .chrow:focus .pl { color: var(--dark); }
.chpanel .help { color: var(--muted); font-size: 13px; padding-top: 8px; }

@media (max-width: 760px) {
  .home header { padding: 18px; }
  .cards { flex-direction: column; gap: 16px; }
  .homecard { width: 70vw; aspect-ratio: auto; padding: 18px; }
  .homecard img { width: 90px; }
  .search { width: 40vw; }
  .topbar .brand .word, .topbar h2 { font-size: 20px; }
  .detail { flex-direction: column; padding: 20px; }
  .detail .poster { width: 160px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 10px 14px 40px; }
}
