/* ===== Base ===== */
:root {
  --bg: #0f1115;
  --bg-soft: #151821;
  --card: #1a1e28;
  --card-hover: #202531;
  --line: #2a3040;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, .14);
  --ok: #37d67a;
  --radius: 14px;
  --player-h: 76px;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar siempre a los display de las clases */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  padding-bottom: calc(var(--player-h) + 24px);
  background: radial-gradient(1200px 600px at 50% -10%, #1b2030 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, p { margin: 0; }

/* ===== Cabecera ===== */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 20px 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 8px 18px -10px #000;
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand h1 a,
.brand h1 a:hover { color: inherit; text-decoration: none; }
.brand h1 a:hover { color: var(--accent); }

.tagline { font-size: 13px; color: var(--muted); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset;
}

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a0d06;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* ===== Layout ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.foot {
  padding: 0 20px 28px;
  text-align: center;
  font-size: 12px;
  color: #6f7789;
}

/* ===== Filtros ===== */
.filters {
  display: grid;
  grid-template-columns: 1fr 200px 190px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.filters input[type="search"],
.filters select {
  width: 100%;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  min-width: 0;
}

.filters input[type="search"]::placeholder { color: #6f7789; }

.filters input[type="search"]:hover,
.filters select:hover { border-color: #3a4256; }

.filters select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2398a0b3' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
  cursor: pointer;
}

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}

.btn:hover { background: var(--card-hover); border-color: #3a4256; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #1a0d06;
  font-weight: 700;
}

.btn.primary:hover { background: #ff7d4d; }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card); }
.btn.small { padding: 7px 12px; font-size: 13px; }

.filters .toggle {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: -2px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.filters .toggle:hover { color: var(--text); }
.filters .toggle input { width: auto; margin: 0; accent-color: var(--accent); }

/* ===== Estado ===== */
.status {
  min-height: 22px;
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.status.error { color: #ff8a80; }
.status.loading::after {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse .9s ease-in-out infinite;
}

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

/* ===== Rejilla de emisoras ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}

.card:hover { background: var(--card-hover); border-color: #3a4256; }

.card.is-playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 8px 24px -12px var(--accent);
}

.card.is-blocked { opacity: .75; }
.card.is-blocked .play { opacity: .55; cursor: not-allowed; }

.tag.warn { background: #3a2a1f; color: #ffb37a; }

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.art {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  background: #212734 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='70'%3E%F0%9F%93%BB%3C/text%3E%3C/svg%3E") center/70% no-repeat;
  display: grid;
  place-items: center;
}

.art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0c0e13;
}

.info { min-width: 0; flex: 1; }

.name {
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sub {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #232937;
  color: #a9b2c6;
  white-space: nowrap;
}

.star {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #6f7789;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, background .15s, transform .1s;
}

.star:hover { background: #262c3a; color: #ffc247; }
.star[aria-pressed="true"] { color: #ffc247; }
.star:active { transform: scale(.9); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions .play {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #202634;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.card-actions .play:hover { background: #293040; border-color: #3a4256; }

.card.is-playing .play {
  background: var(--accent);
  border-color: transparent;
  color: #1a0d06;
  font-weight: 700;
}

.more-wrap { display: flex; justify-content: center; margin-top: 22px; }

/* ===== Reproductor ===== */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--player-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: rgba(16, 19, 26, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.pp {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #1a0d06;
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, transform .1s;
}

.pp:hover { background: #ff7d4d; }
.pp:active { transform: scale(.95); }

.pp.close {
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  width: 38px;
  height: 38px;
}

.pp.close:hover { background: var(--card); color: var(--text); }

.now {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.now strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.now .err { color: #ff8a80; }

.volume {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
}

.volume input {
  width: 110px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .filters .btn.primary { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { padding: 18px 16px 12px; }
  main { padding: 0 16px 32px; }
  .grid { grid-template-columns: 1fr; }
  .player { gap: 10px; padding: 0 12px; }
  .volume input { width: 70px; }
  .player .btn.small { display: none; }
}
