:root {
  --accent: #F4C91B;
  --bg-top: #1a1a1a;
  --bg-mid: #111111;
  --bg-bottom: #0a0a0a;
  --text: #F5F1EC;
  --text-muted: #B9AFA9;
  --text-dim: #8C8480;
  --card: #232323;
  --card-2: #161616;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-bottom);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; border: none; background: none; color: inherit; cursor: pointer; padding: 0; }
a { color: inherit; }

.app {
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* Top bar */
.topbar {
  padding: max(22px, env(safe-area-inset-top)) 22px 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.live-pill { display: flex; align-items: center; gap: 6px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.live-dot.pulsing { animation: pulse-dot 1.4s ease-in-out infinite; }
.live-label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; color: var(--accent); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

#viewLive {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#viewLive[hidden], #viewSchedule[hidden], #viewFavorites[hidden] {
  display: none;
}

/* Favoritos */
.fav-empty { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }
.fav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.fav-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: #1a1a1a; }
.fav-text { flex: 1; min-width: 0; }
.fav-song { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-artist { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.fav-remove {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  color: var(--text-dim); font-size: 14px;
  background: rgba(255,255,255,.05);
}

/* Middle */
.middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}

.cover {
  width: min(270px, 70vw);
  height: min(270px, 70vw);
  border-radius: 22px;
  background: linear-gradient(145deg, var(--card) 0%, var(--card-2) 100%);
  box-shadow: 0 25px 60px -15px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.06) inset;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cover svg { stroke: #4A4642; }
.cover img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* carátula completa, sin recortes */
  border-radius: 22px;
  display: block;
}
.cover img[hidden] {
  display: none;
}
#coverLogo { object-fit: cover; }

.track-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.6px;
  color: var(--accent); text-transform: uppercase;
}
.track-title { margin-top: 7px; font-size: 18px; font-weight: 700; }
.track-artist { margin-top: 2px; font-size: 13.5px; color: var(--text-muted); }
.status-text { font-size: 12px; color: var(--text-dim); margin-top: -12px; }

.station { line-height: 1.3; }
.station-name { font-size: 15px; font-weight: 700; color: var(--text); }
.station-location { font-size: 13px; color: var(--text-muted); }

.vol-icon[hidden] { display: none; }
.vol-icon.casting svg { stroke: var(--accent); }

.eq { display: flex; align-items: flex-end; justify-content: center; gap: 5px; height: 28px; }
.eq span { width: 5px; border-radius: 3px; background: var(--accent); height: 10px; }
.eq.playing span:nth-child(1) { animation: eq 0.9s ease-in-out infinite 0s; }
.eq.playing span:nth-child(2) { animation: eq 0.9s ease-in-out infinite 0.15s; }
.eq.playing span:nth-child(3) { animation: eq 0.9s ease-in-out infinite 0.3s; }
.eq.playing span:nth-child(4) { animation: eq 0.9s ease-in-out infinite 0.15s; }
.eq.playing span:nth-child(5) { animation: eq 0.9s ease-in-out infinite 0s; }
@keyframes eq { 0%, 100% { height: 10px; } 50% { height: 26px; } }

/* Controls */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 30px;
  padding-bottom: 22px;
}
.ghost-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
}
.ghost-btn.active { background: rgba(244,201,27,.18); }
.ghost-btn svg { stroke: var(--text); }
.ghost-btn.active svg { stroke: var(--accent); fill: var(--accent); }

.play-btn {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px -6px var(--accent);
}
.play-btn svg { fill: #121212; }

/* Volumen */
.volume {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 34px max(22px, env(safe-area-inset-bottom)) 34px;
}
.vol-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.vol-icon svg { stroke: var(--text); }
.vol-icon.muted svg { stroke: var(--text-dim); }
.volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--vol, 80%), rgba(255,255,255,.15) var(--vol, 80%), rgba(255,255,255,.15) 100%);
  outline: none;
}
.volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  cursor: pointer;
}
.volume input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.play-btn.loading { opacity: .75; }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(18,18,18,.35);
  border-top-color: #121212;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  margin: 0 22px 14px 22px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(220, 70, 60, .12);
  border: 1px solid rgba(220, 70, 60, .35);
  color: #ffb3ab;
  font-size: 12.5px;
  text-align: center;
  display: none;
}
.error-banner.show { display: block; }

.install-banner {
  margin: 0 22px 14px 22px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(244,201,27,.1);
  border: 1px solid rgba(244,201,27,.35);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--accent); color: #121212; font-weight: 700;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; white-space: nowrap;
}

/* Programación */
.schedule-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.schedule-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 22px 10px 22px;
}
.schedule-day {
  margin-bottom: 22px;
}
.schedule-day-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.schedule-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  margin-bottom: 8px;
}
.schedule-block-time {
  flex: 0 0 auto;
  min-width: 108px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.schedule-block-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Bottom tabs */
.tabbar {
  display: flex; align-items: center; justify-content: space-around;
  padding: 12px 10px max(18px, env(safe-area-inset-bottom)) 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.22);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 60px; padding: 6px 0; font-size: 10.5px; color: var(--text-dim);
}
.tab.active { color: var(--accent); font-weight: 700; }
.tab.active svg { stroke: var(--accent); }
.tab svg { stroke: var(--text-dim); }

/* Menú propio para compartir */
.share-sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.share-sheet[hidden] { display: none; }
.share-card {
  width: 100%; max-width: 480px;
  background: #1a1a1a;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
.share-title { font-size: 14px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 4px; }
.share-opt {
  display: block; text-align: center; text-decoration: none;
  padding: 14px; border-radius: 12px;
  background: rgba(255,255,255,.07); color: var(--text);
  font-size: 15px; font-weight: 600;
}
.share-opt.share-wa { background: var(--accent); color: #121212; }
.share-cancel { padding: 12px; color: var(--text-dim); font-size: 14px; }
.share-opt.share-wa, .share-opt.share-row { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; font-family: inherit; border: 0; cursor: pointer; }
.share-opt.share-row:active { background: rgba(244,201,27,.2); }
.share-hint {
  font-size: 12.5px; line-height: 1.45; text-align: center;
  color: #121212; background: var(--accent);
  border-radius: 10px; padding: 9px 12px;
}
.share-hint[hidden] { display: none; }

/* Redes de la radio (arriba, al costado del logo) */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; }
.topbar > img { justify-self: start; }
.topbar .live-pill { justify-self: end; }
.socials { display: flex; align-items: center; justify-content: center; gap: 10px; }
.social {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.08); color: var(--text);
  text-decoration: none;
}
.social:active { background: rgba(244,201,27,.25); color: var(--accent); }
.social[hidden] { display: none; }

/* Reproductor en PC: mini reproductor */
#miniBtn[hidden], #expandBtn[hidden] { display: none; }
body.mini .topbar, body.mini .error-banner, body.mini .install-banner, body.mini .station,
body.mini .eq, body.mini .status-text, body.mini .volume, body.mini .tabbar,
body.mini #viewSchedule, body.mini #viewFavorites, body.mini #shareBtn,
body.mini .share-sheet { display: none !important; }
body.mini .app { min-height: 100vh; max-width: none; justify-content: center; }
body.mini #viewLive { display: flex !important; flex-direction: row; flex: none; align-items: center; gap: 10px; padding: 0 12px; height: 100vh; }
body.mini .middle { flex-direction: row; align-items: center; gap: 12px; padding: 0; flex: 1; min-width: 0; text-align: left; justify-content: flex-start; }
body.mini .middle > div:nth-child(2) { min-width: 0; }
body.mini .cover { width: 72px; height: 72px; border-radius: 10px; flex: none; box-shadow: none; }
body.mini .cover img { border-radius: 10px; }
body.mini .track-eyebrow { font-size: 9.5px; }
body.mini .track-title { margin-top: 3px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.mini .track-artist { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.mini .controls { gap: 8px; padding: 0; }
body.mini .ghost-btn { width: 36px; height: 36px; }
body.mini .play-btn { width: 52px; height: 52px; box-shadow: none; }
.pip-placeholder {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg-bottom); color: var(--text); text-align: center; padding: 24px;
}
.pip-placeholder[hidden] { display: none; }
.pip-placeholder img { width: 96px; height: 96px; border-radius: 18px; }
.pip-placeholder p { margin: 0; font-size: 15px; color: var(--text-muted); max-width: 280px; line-height: 1.45; }
.pip-placeholder button { background: var(--accent); color: #121212; font-weight: 700; padding: 12px 20px; border-radius: 12px; }

/* Volumen dentro del mini reproductor */
.mini-vol { display: none; }
body.mini .mini-vol {
  display: block; width: 100%; max-width: 160px; margin: 8px 0 0;
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; outline: none;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--vol, 80%), rgba(255,255,255,.15) var(--vol, 80%), rgba(255,255,255,.15) 100%);
}
body.mini .mini-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); cursor: pointer; }
body.mini .mini-vol::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* Que todo entre en una sola pantalla (las pestañas siempre a la vista) */
.app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
#viewLive { overflow: hidden; }
.topbar { padding-top: max(clamp(10px, 2.2vh, 22px), env(safe-area-inset-top)); }
.middle { gap: clamp(8px, 1.8vh, 22px); padding: clamp(6px, 1.6vh, 24px) 24px; min-height: 0; }
.cover { width: min(270px, 70vw, 34vh); height: min(270px, 70vw, 34vh); }
.install-banner.show ~ #viewLive .cover,
.error-banner.show ~ #viewLive .cover { width: min(270px, 70vw, 27vh); height: min(270px, 70vw, 27vh); }
.status-text { margin-top: calc(clamp(8px, 1.8vh, 22px) * -0.5); }
.play-btn { width: clamp(60px, 9vh, 76px); height: clamp(60px, 9vh, 76px); }
.controls { padding-bottom: clamp(8px, 1.8vh, 22px); }
.volume { padding-bottom: clamp(8px, 1.6vh, 22px); }
.tabbar { flex: none; padding-top: 8px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
@media (max-height: 620px) { .station { display: none; } }
