:root {
  --fondo: #0f0f0f; --capa: #181818; --capa2: #272727; --capa3: #3f3f3f;
  --borde: #ffffff1a; --texto: #f1f1f1; --tenue: #aaa; --tenue2: #717171;
  --rojo: #e62117; --rosa: #ff2791; --azul: #3ea6ff;
  --barra-alta: calc(60px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; width: 100%; max-width: 100vw; overflow: hidden; }
body {
  background: var(--fondo); color: var(--texto);
  font-family: Roboto, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; user-select: none;
}
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }

#app { height: 100%; width: 100vw; max-width: 100vw; display: flex; flex-direction: column; overflow-x: hidden; }

/* Contenido con scroll */
#vista {
  flex: 1; width: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
}
#vista.con-barra { padding-bottom: 76px; }

/* Barra de arriba */
.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px; }
.logo { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 18px; letter-spacing: -.5px; }
.logo .r { width: 30px; height: 21px; background: var(--rojo); border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; }
.logo .r svg { width: 13px; height: 13px; }
.logo small { font-weight: 400; color: var(--tenue); font-size: 14px; }
.top .acciones { display: flex; gap: 4px; }
.iconobtn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 22px; border-radius: 50%; }
.iconobtn:active { background: var(--capa2); }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--capa2); border-radius: 8px; padding: 7px 12px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--texto); color: var(--fondo); }

/* Tarjeta de video grande */
.tv { padding-bottom: 18px; }
.tv .mini { position: relative; margin: 0 12px; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: var(--capa2); }
.tv .mini img { width: 100%; height: 100%; object-fit: cover; }
.dur { position: absolute; right: 8px; bottom: 8px; background: #000c; color: #fff; font-size: 12px; font-weight: 500; padding: 1px 4px; border-radius: 4px; }
.tv .meta { display: flex; gap: 12px; padding: 10px 12px 0; }
.av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 500; }
.tv .meta .t { flex: 1; min-width: 0; }
.tv .meta .t b { font-size: 15px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tv .meta .t small { color: var(--tenue); font-size: 12.5px; }
.tv .meta .op { font-size: 22px; color: var(--texto); align-self: flex-start; padding: 0 2px; }

.cargando { text-align: center; color: var(--tenue); padding: 40px 20px; }
.spin { width: 28px; height: 28px; border: 3px solid var(--capa3); border-top-color: var(--texto); border-radius: 50%; animation: giro .8s linear infinite; margin: 30px auto; }
@keyframes giro { to { transform: rotate(360deg); } }
.sinconx { display: flex; align-items: center; gap: 10px; margin: 8px 12px 14px; background: var(--capa2); border-radius: 12px; padding: 11px 14px; font-weight: 500; }

/* Buscar */
.buscar-top { display: flex; gap: 6px; align-items: center; padding: 8px 10px; }
.buscar-top input {
  flex: 1; background: var(--capa2); border: 0; border-radius: 99px; color: var(--texto);
  font-size: 16px; padding: 11px 16px; outline: none;
}
.sug { padding: 12px 16px; border-bottom: 1px solid var(--borde); font-size: 15px; display: flex; align-items: center; gap: 12px; }
.sug .ic { color: var(--tenue); }

/* Barrita del reproductor */
.barra { position: fixed; left: 0; right: 0; bottom: var(--barra-alta); background: #212121; z-index: 40; }
.barra.oculto { display: none; }
.barra .fila { display: flex; align-items: center; height: 60px; }
.barra .hueco { width: 107px; height: 60px; flex: none; background: #000; }
.barra .info { flex: 1; min-width: 0; padding: 0 10px; }
.barra .info b { font-size: 14px; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .info small { color: var(--tenue); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .b { font-size: 26px; padding: 0 10px; }
.barra .prog { height: 2px; background: #fff2; }
.barra .prog > i { display: block; height: 100%; background: linear-gradient(90deg, var(--rojo), var(--rosa)); width: 0; }

/* Navegación */

.nav { display: flex; width: 100%; background: var(--fondo); border-top: .5px solid var(--borde); padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; font-size: 10px; color: var(--texto); }
.nav button .ic { font-size: 21px; }
.nav button:not(.activo) { color: #cfcfcf; }
.nav button.activo { font-weight: 600; }

/* Panel grande */
.panel { position: fixed; inset: 0; background: var(--fondo); z-index: 60; transform: translateY(100%); transition: transform .3s cubic-bezier(.3,.7,.2,1); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.panel.abierto { transform: translateY(0); }
.panel .pbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.panel .pbar button { font-size: 28px; width: 44px; height: 44px; }
.panel .hueco-g { width: 100%; aspect-ratio: 16/9; background: #000; }
.panel .cuerpo { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel .prog-g { height: 3px; background: #fff3; }
.panel .prog-g > i { display: block; height: 100%; background: linear-gradient(90deg, var(--rojo), var(--rosa)); width: 0; }
.panel h1 { font-size: 18px; font-weight: 700; margin: 12px 14px 0; line-height: 1.3; }
.panel .canal { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.panel .canal b { font-weight: 500; font-size: 14.5px; }
.pastillas { display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 10px; scrollbar-width: none; }
.pastillas::-webkit-scrollbar { display: none; }
.pastilla { flex: none; background: var(--capa2); border-radius: 99px; padding: 8px 14px; font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.pastilla.on { color: var(--azul); }
.controles { display: flex; align-items: center; justify-content: space-evenly; padding: 6px 24px 14px; }
.controles .pp { width: 62px; height: 62px; border-radius: 50%; background: var(--texto); color: var(--fondo); display: flex; align-items: center; justify-content: center; font-size: 30px; }
.controles .sk { font-size: 34px; }

/* El reproductor de YouTube: posicionado por JS */
#yt-caja { position: fixed; z-index: 45; overflow: hidden; background: #000; transition: none; }
#yt-caja.oculto { opacity: 0; pointer-events: none; }
#yt-player, #yt-player iframe { width: 100%; height: 100%; border: 0; }

/* Audio/video de descargas (reproductor nativo, da AirPlay) */
#media-local { display: none; }

.vacio { text-align: center; color: var(--tenue); padding: 60px 30px; line-height: 1.5; }
.vacio .big { font-size: 56px; margin-bottom: 14px; }
.titulo-sec { font-size: 19px; font-weight: 700; padding: 16px 14px 8px; }

/* Sin internet (etiqueta en el panel) */
.sininet { margin-left: auto; background: var(--capa2); border-radius: 99px; padding: 4px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; color: var(--azul); }

/* Descargas */
.dl-resumen { color: var(--azul); font-size: 13px; padding: 2px 14px 10px; }
.dl-fila { display: flex; align-items: center; gap: 12px; padding: 7px 10px; }
.dl-fila .mini-s { position: relative; width: 120px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--capa2); flex: none; }
.dl-fila .mini-s img { width: 100%; height: 100%; object-fit: cover; }
.dl-fila .mini-s .dur { position: absolute; right: 3px; bottom: 3px; background: #000c; color: #fff; font-size: 11px; padding: 0 3px; border-radius: 3px; }
.dl-fila .t { flex: 1; min-width: 0; }
.dl-fila .t b { font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.dl-fila .t small { color: var(--tenue); font-size: 12px; }
.dl-fila .op { font-size: 20px; color: var(--texto); padding: 0 4px; align-self: flex-start; }
.barra-dl { height: 3px; background: var(--capa3); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.barra-dl > i { display: block; height: 100%; background: var(--azul); width: 0; }

/* Cuenta */
.cuenta-caja { text-align: center; padding: 30px 24px; width: min(380px, 100%); margin: 0 auto; }
.cuenta-caja .big { font-size: 54px; margin-bottom: 10px; }
.cuenta-caja b { font-size: 17px; display: block; margin-bottom: 4px; }
.cuenta-caja p { color: var(--tenue); font-size: 13.5px; line-height: 1.5; margin: 6px 0 16px; }
.cuenta-caja input { width: 100%; background: var(--capa2); border: 0; border-radius: 10px; color: var(--texto); font-size: 16px; padding: 13px 16px; outline: none; margin-bottom: 12px; }
.boton { width: 100%; background: var(--texto); color: var(--fondo); border-radius: 99px; padding: 13px; font-size: 15px; font-weight: 600; }
.boton.gris { background: var(--capa2); color: var(--texto); }
.cuenta-caja .err { color: var(--rojo); font-size: 13px; margin-top: 10px; }

/* Botón descargar en la tarjeta */
.tv .meta .dl { font-size: 20px; color: var(--texto); align-self: flex-start; padding: 0 4px; }
.pastilla.on { color: var(--azul); }

/* Hoja (menú) */
.hoja-bg { position: fixed; inset: 0; background: #0008; z-index: 80; display: flex; align-items: flex-end; }
.hoja { width: 100%; background: #282828; border-radius: 14px 14px 0 0; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; animation: subir .2s ease; }
@keyframes subir { from { transform: translateY(100%); } }
.hoja .agarre { width: 36px; height: 4px; background: #666; border-radius: 2px; margin: 4px auto 8px; }
.hoja-tit { font-size: 13px; color: var(--tenue); padding: 4px 22px 8px; }
.hoja-op { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 14px 22px; font-size: 15px; }
.hoja-op span { width: 22px; text-align: center; }
.hoja-op:active { background: #ffffff14; }

/* Aviso (toast) */
#aviso { position: fixed; left: 50%; bottom: calc(var(--barra-alta) + 70px); transform: translateX(-50%) translateY(10px); background: #f1f1f1; color: #0f0f0f; font-size: 14px; font-weight: 500; padding: 11px 18px; border-radius: 8px; max-width: 90%; text-align: center; z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#aviso.ver { opacity: 1; transform: translateX(-50%) translateY(0); }

#media-local.oculto { display: none; }
.cuenta-nota { color: var(--tenue2); font-size: 12px; line-height: 1.5; margin-top: 18px; border-top: 1px solid var(--borde); padding-top: 14px; }
