:root {
  --bg: #0f141b;
  --panel: #17202b;
  --line: #263243;
  --txt: #eef2f7;
  --mut: #97a3b4;
  --acc: #2f7cf6;
  --on-acc: #ffffff;
  --live: #ff3b3b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body { display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); overflow: hidden; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- Paneles ---------- */
main { flex: 1 1 auto; min-height: 0; position: relative; order: 1; }
.panel { position: absolute; inset: 0; display: none; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel.on { display: flex; }
.vista { display: none; flex: 1 1 auto; flex-direction: column; min-height: 100%; }
.vista.on { display: flex; }

/* ---------- Encabezado con la marca (celular) ---------- */
.marca {
  display: flex; align-items: center; justify-content: center;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--line);
}
.marca img { max-height: 64px; max-width: min(320px, 82%); width: auto; height: auto; }
.marca b { font-size: 1.35rem; letter-spacing: -.01em; }

/* ---------- Grilla de logos ---------- */
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 16px 28px; }
.titulo { margin: 4px 2px 14px; font-size: 1.15rem; font-weight: 700; }
.grilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 821px) { .grilla { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  padding: 12px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--panel); cursor: pointer; text-align: center;
  transition: transform .15s, border-color .15s;
}
.tile:hover { border-color: var(--c1, var(--acc)); }
.tile:active { transform: scale(.97); }
.tile:focus-visible { outline: 3px solid var(--txt); outline-offset: 3px; }
.tile .cara {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--c2, #fff); display: grid; place-items: center;
}
.tile .cara img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .cara .ini { font-size: 2rem; font-weight: 800; color: var(--c1); }
.tile .nom { font-size: .88rem; font-weight: 600; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.sonando { border-color: var(--c1); box-shadow: 0 0 0 1px var(--c1); }
.tile.sonando .nom { color: var(--txt); }
.badge {
  position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 999px;
  font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(0, 0, 0, .72); color: #fff;
}
.badge.vivo { background: var(--live); }
.vacio { color: var(--mut); text-align: center; padding: 40px 10px; }

/* ---------- Barra superior de una vista (volver) ---------- */
.volver-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.volver {
  border: 0; background: transparent; color: var(--acc); font-weight: 600;
  padding: 8px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.volver svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.volver-bar .cual { font-weight: 700; margin-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Reproductor de radio ---------- */
#v-player { background: radial-gradient(ellipse 90% 60% at 50% 0%, var(--glow, rgba(47, 124, 246, .18)), transparent 70%), var(--bg); }
#v-player .volver { color: var(--acc); }
.player {
  width: 100%; max-width: 420px; margin: auto; padding: 22px 24px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
}
.envivo {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  font-size: .74rem; font-weight: 700; letter-spacing: .12em; color: var(--mut);
}
.envivo i { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); }
.player.sonando .envivo { color: var(--txt); }
.player.sonando .envivo i { background: var(--live); animation: latido 1.4s ease-in-out infinite; }
@keyframes latido { 50% { opacity: .35; } }

.tapa {
  position: relative; width: min(250px, 66vw); aspect-ratio: 1; border-radius: 20px; overflow: hidden;
  background: var(--c2, #fff); border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.tapa img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tapa #pLogo { object-fit: contain; }
.tapa #pArte { object-fit: cover; }
.tapa img[hidden] { display: none; }
.player h1 { margin: -4px 0 0; font-size: 1.3rem; }

.suena { min-height: 46px; display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.suena[hidden] { display: none; }
.suena small { font-size: .72rem; font-weight: 700; letter-spacing: .12em; color: var(--acc); }
.suena span { font-size: 1.02rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }

.play {
  width: 84px; height: 84px; border: 0; border-radius: 50%;
  background: var(--acc); color: var(--on-acc); cursor: pointer;
  display: grid; place-items: center; transition: transform .15s;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.play:active { transform: scale(.95); }
.play:focus-visible { outline: 3px solid var(--txt); outline-offset: 4px; }
.play:disabled { opacity: .4; cursor: not-allowed; }
.play svg { width: 36px; height: 36px; fill: currentColor; }
.play .ic-pausa, .player.sonando .play .ic-play { display: none; }
.player.sonando .play .ic-pausa { display: block; }
.player.sonando .play { animation: onda 2.2s infinite; }
@keyframes onda { 0% { box-shadow: 0 0 0 0 var(--glow2, rgba(47, 124, 246, .5)); } 100% { box-shadow: 0 0 0 22px rgba(0, 0, 0, 0); } }
.player.cargando .play svg { opacity: .45; }
.estado { min-height: 1.2em; margin-top: -8px; font-size: .85rem; color: var(--mut); }

.volumen { display: none; align-items: center; gap: 10px; width: 220px; color: var(--mut); }
.volumen svg { width: 20px; height: 20px; flex: none; fill: currentColor; }
.volumen input { flex: 1; accent-color: var(--acc); }
@media (hover: hover) and (pointer: fine) { .volumen { display: flex; } }

/* ---------- Mini reproductor (radio sonando en otra vista) ---------- */
.mini {
  flex: 0 0 auto; order: 2; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--panel); border-top: 1px solid var(--line);
}
.mini[hidden] { display: none; }
.mini .abrir { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; padding: 0; }
.mini .abrir img { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: var(--c2, #fff); flex: none; }
.mini .abrir span { display: flex; flex-direction: column; min-width: 0; }
.mini .abrir b { font-size: .92rem; }
.mini .abrir small { color: var(--mut); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .parar {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: var(--c1, var(--acc)); color: var(--on1, #fff); display: grid; place-items: center;
}
.mini .parar svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- TV ---------- */
#v-tvver iframe { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; display: block; background: #000; }
#v-tvver { min-height: 0; height: 100%; }

/* ---------- Noticias ---------- */
.news-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 14px; }
.news-head h2 { margin: 0; font-size: 1.15rem; }
.news-head a { color: var(--acc); font-size: .85rem; text-decoration: none; }
.card {
  display: flex; gap: 12px; width: 100%; padding: 10px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  color: inherit; text-align: left; font: inherit; cursor: pointer;
}
.card:active { transform: scale(.99); }
.card img { flex: 0 0 auto; width: 112px; height: 84px; object-fit: cover; border-radius: 10px; background: var(--line); }
.card .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card .meta { font-size: .72rem; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; }
.card .meta b { color: var(--acc); font-weight: 700; }
.card h3 { margin: 0; font-size: .98rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card.big { flex-direction: column; }
.card.big img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
.card.big h3 { font-size: 1.12rem; }
.msg { text-align: center; color: var(--mut); padding: 40px 10px; }
.msg button { margin-top: 12px; border: 0; border-radius: 999px; padding: 9px 18px; background: var(--acc); color: var(--on-acc); font-weight: 600; cursor: pointer; }
#v-nota iframe { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #fff; }
#v-nota { height: 100%; }

/* ---------- Pestañas ---------- */
.tabs { flex: 0 0 auto; display: flex; background: var(--bg); border-top: 1px solid var(--line); order: 3; padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs .brand { display: none; }
.tab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 64px; border: 0; background: transparent; color: var(--mut); font-size: .82rem; font-weight: 600; cursor: pointer;
}
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--acc); }

/* ---------- Barra de instalación ---------- */
.barra {
  flex: 0 0 auto; order: 2; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); color: #d4dbe6; font-size: 14px;
}
.barra[hidden] { display: none; }
.barra button { border: 0; cursor: pointer; font-weight: 600; padding: 9px 18px; border-radius: 999px; background: var(--acc); color: var(--on-acc); }
.barra button[hidden] { display: none; }
.barra button.cerrar { background: transparent; color: var(--mut); padding: 9px 12px; font-size: 18px; line-height: 1; }

/* ---------- Web: barra larga arriba ---------- */
@media (min-width: 821px) {
  .marca { display: none; }
  .tabs { order: 0; border-top: 0; border-bottom: 1px solid var(--line); padding: 0 24px; align-items: center; gap: 6px; }
  .tabs .brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-weight: 700; font-size: 1.05rem; }
  .tabs .brand img { max-height: 40px; width: auto; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 8px; height: 60px; padding: 0 18px; font-size: .95rem; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
  .tab svg { width: 22px; height: 22px; }
  .tab:hover { color: var(--txt); }
  .tab.on { border-bottom-color: var(--acc); }
  .barra { order: 4; }
  .wrap { max-width: 1000px; padding-top: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .player.sonando .play, .player.sonando .envivo i { animation: none; }
}

/* ---------- Servicio suspendido ---------- */
.suspendido { margin: auto; max-width: 460px; padding: 32px 24px; text-align: center; }
.suspendido h1 { font-size: 1.5rem; margin: 0 0 10px; }
.suspendido p { color: var(--mut); line-height: 1.5; margin: 0; }

/* ---- Multiradios: género, tanda y una sola pestaña ---- */
.tile .gen { font-size: .74rem; color: var(--mut); opacity: .8; margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .genero { margin: -10px 0 0; font-size: .85rem; color: var(--mut); }
.player.tanda .envivo i { background: #f5a524; animation: none; }
.player.tanda .envivo { color: #f5a524; }
.tabs.solo { display: none; }
@media (min-width: 821px) {
  .tabs.solo { display: flex; }
  .tabs.solo .tab { display: none; }
  .tabs.solo .brand { margin-right: 0; height: 60px; }
}

/* Insertada en otro sitio */
body.fija .tabs, body.fija .volver-bar, body.fija .mini { display: none !important; }
