* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --bg: #121212;
  --bg-raised: #1c1c1c;
  --bg-active: #2a2a2a;
  --text: #ffffff;
  --text-dim: #a7a7a7;
  --accent: #0bc9f9;
  --player-h: 108px;
}

html { color-scheme: dark; height: 100%; }

body {
  height: 100%;
  /* dvh para que la altura sea la que se ve, sin la barra del navegador. */
  height: 100dvh;
  /* El documento no scrollea: el scroll vive adentro de #app. Así el player
     de abajo nunca se mueve al cambiar de pantalla, y el navegador no entra
     ni sale su barra de herramientas al scrollear. */
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 16px
    calc(var(--player-h) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* El ancho lo limita cada pantalla, no #app: así la barra de scroll queda
   contra el borde de la ventana y no en medio del contenido. */
#app > section {
  max-width: 640px;
  margin: 0 auto;
}

/* ── Cabecera ── */
.hero {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  padding: 24px 0 20px;
  background: linear-gradient(180deg, rgba(0, 180, 248, 0.28), transparent);
  border-radius: 12px;
  padding: 20px;
}

.hero-cover {
  width: 116px;
  height: 116px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #000000 center / cover url("icons/cover.jpg");
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hero-kicker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.hero h1 {
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0;
}

.hero-subtitle { color: var(--text-dim); font-size: 14px; }
.hero-meta { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

/* ── Métricas del programa ── */
.show-stats {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  padding: 18px 4px 0;
  /* Toda la línea entra en un solo renglón, también en el teléfono. */
  font-size: clamp(10px, 3.1vw, 13px);
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

.stat-part { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.stat-part:not(.stat-first)::before { content: "·"; color: #5d5d5d; }
.stat-star { color: var(--accent); }

#stat-rank-part { color: #e6e6e6; }
#stat-rating { color: #e6e6e6; }
#stat-genre-part { font-weight: 400; }

/* Si algún teléfono raro queda corto de ancho, lo único que se recorta
   es el paréntesis: la línea nunca pasa a dos renglones. */
#stat-score-part { flex-shrink: 1; min-width: 0; }
.stat-note { font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.show-joke {
  padding: 8px 4px 4px;
  color: #7d7d7d;
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
}

/* ── Convite a tenerla como app ── */
.install {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 4px 2px;
  padding: 10px 12px;
  border: 1px solid #2f2f2f;
  border-radius: 12px;
  background: var(--bg-raised);
}

.install-cover {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 9px;
  background: #000000 center / cover url("icons/cover.jpg");
}

.install-body { flex: 1; min-width: 0; }
.install-title { font-size: 14px; font-weight: 700; }
.install-sub { margin-top: 2px; color: var(--text-dim); font-size: 12px; }

.install-go {
  flex-shrink: 0;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.1s;
}
.install-go:hover { filter: brightness(1.1); }

.install-hide {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 0;
  background: none;
  color: #7a7a7a;
  cursor: pointer;
}
.install-hide:hover { color: var(--text); }

/* ── Hoja con los pasos para instalar ── */
.sheet {
  width: min(560px, calc(100% - 28px));
  max-height: min(760px, 88dvh);
  margin: auto;
  padding: 0;
  border: 1px solid #353535;
  border-radius: 18px;
  background: #181818;
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.76); backdrop-filter: blur(4px); }

.sheet-body {
  max-height: min(760px, 88dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 28px;
}

.sheet-handle {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 38px;
  height: 4px;
  margin: 10px auto 4px;
  border-radius: 99px;
  background: #5d5d5d;
}

.sheet-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 12px;
  background: linear-gradient(#181818 84%, rgba(24, 24, 24, 0));
}

.sheet-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sheet-header h2 {
  margin-top: 5px;
  font-size: clamp(20px, 5vw, 26px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.sheet-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #2a2a2a;
  color: var(--text);
  cursor: pointer;
}

.sheet-intro { color: #d6d6d6; font-size: 14px; line-height: 1.5; }

.steps { margin-top: 22px; }

.steps-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e6e6e6;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.steps-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(11, 201, 249, 0.16);
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.steps-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 0 18px;
  color: #d6d6d6;
  font-size: 14px;
  line-height: 1.45;
}
.steps-list b { color: var(--text); font-weight: 700; }

.steps-note { margin-top: 8px; color: #858585; font-size: 12px; line-height: 1.45; }

/* ── Botón de play grande de la pantalla del episodio ── */
.actions { padding: 16px 4px; }

.btn-primary {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}
.btn-primary:hover { transform: scale(1.05); filter: brightness(1.1); }

/* ── Lista de episodios ── */
.episodes { list-style: none; }

.episode {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.episode:hover { background: var(--bg-raised); }
.episode:focus-visible { background: var(--bg-raised); outline: 2px solid var(--accent); outline-offset: -2px; }
.episode.playing { background: var(--bg-active); }

.episode-artwork {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.episode-art {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-raised);
}

.episode-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.65));
  color: var(--text);
  padding: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.episode-play > * { grid-area: 1 / 1; }
.episode-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.episode-index {
  align-self: end;
  justify-self: start;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.episode.playing .episode-index { color: var(--accent); }

/* Al pasar por encima, el número se convierte en un play. */
.episode-play-icon { display: none; color: var(--text); }
.episode:hover .episode-play { background: rgba(0, 0, 0, 0.52); }
.episode:hover .episode-play-icon { display: block; }
.episode:hover .episode-index { visibility: hidden; }
.episode.playing.active-sound .episode-play-icon { display: none; }

.episode-body { flex: 1; min-width: 0; }

.episode-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.episode.playing .episode-title { color: var(--accent); }
.episode.listened .episode-title { color: var(--text-dim); font-weight: 400; }

.episode-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 7px;
}

.episode-summary {
  color: #c7c7c7;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.episode-check {
  color: var(--accent);
  flex-shrink: 0;
  display: none;
}
.episode.listened .episode-check { display: block; }

.episode-duration {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
  padding-top: 2px;
}

/* animated bars of the playing episode */
.eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  width: 32px;
  height: 32px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  justify-content: center;
}
.episode.playing.active-sound .eq { display: flex; }
.episode.playing.active-sound .episode-index { display: none; }
.eq span {
  width: 3px;
  background: var(--accent);
  animation: eq 0.9s ease-in-out infinite;
}
.eq span:nth-child(2) { animation-delay: 0.25s; }
.eq span:nth-child(3) { animation-delay: 0.5s; }
@keyframes eq {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

.empty {
  color: var(--text-dim);
  padding: 32px 12px;
  line-height: 1.6;
}
.empty code {
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* ── Pantalla de un episodio ── */
/* Como en las apps de podcasts: la tapa grande y centrada arriba,
   y el título abajo, alineado a la izquierda. */
.ep-hero {
  padding: 16px 16px 12px;
  background: linear-gradient(180deg, rgba(0, 180, 248, 0.22), transparent 78%);
  border-radius: 12px;
}

.ep-hero-cover {
  width: min(300px, 68vw);
  aspect-ratio: 1;
  margin: 8px auto 24px;
  border-radius: 12px;
  background: #000000 center / cover;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.ep-hero-title {
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.ep-hero-kicker {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.ep-hero-meta {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 8px 8px 0;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

.ep-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ep-location {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 13px;
}
.ep-location svg { flex-shrink: 0; color: var(--accent); }

.ep-block { padding: 8px 4px; }

.ep-block-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.ep-summary {
  font-size: 15px;
  line-height: 1.6;
  color: #d6d6d6;
}

/* ── Fixed player ── */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #181818;
  border-top: 1px solid #282828;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}

.player-seek {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}

.time {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
}
#time-total { text-align: right; }

#seek {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--progress, 0%), #4d4d4d var(--progress, 0%));
  cursor: pointer;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}
#seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  margin: 4px auto 0;
}

.player-now {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.player-cover {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 6px;
  background: #000000 center / cover url("icons/cover.jpg");
}

.player-titles { min-width: 0; }

.now-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-sender {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ctl {
  position: relative;
  border: none;
  background: none;
  color: var(--text-dim);
  padding: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.15s;
}
.ctl:hover { color: var(--text); }

/* El 15 va adentro de la flecha circular del SVG. El círculo está centrado en
   el viewBox, entonces alcanza con centrar el número sobre el botón. */
.ctl-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.btn-play {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin: 0 4px;
  transition: transform 0.1s;
}
.btn-play:hover { transform: scale(1.06); }
.btn-play svg { margin-left: 1px; }
.btn-play #icon-pause { margin-left: 0; }

.btn-speed {
  border: 1px solid #4d4d4d;
  background: none;
  color: var(--text-dim);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
  min-width: 44px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-speed:hover { color: var(--text); border-color: var(--text); }

@media (max-width: 480px) {
  /* En el teléfono las tarjetas van de borde a borde: el margen lateral lo
     pone cada una adentro, así no queda aire a los costados ni arriba. */
  #app {
    padding-top: env(safe-area-inset-top, 0px);
    padding-inline: 0;
  }
  .hero { border-radius: 0; padding-inline: 16px; }
  .show-stats, .show-joke, .actions, .ep-block { padding-inline: 16px; }
  .btn-back { padding-left: 16px; }
  .ep-hero { border-radius: 0; }
  .install {
    margin-inline: 0;
    border-radius: 0;
    border-inline: 0;
    padding-inline: 16px;
  }
  .episode { border-radius: 0; }

  .hero { gap: 14px; }
  .hero-cover { width: 88px; height: 88px; }
  /* Pegada abajo y de lado a lado, como el player. El max-width lo pone
     el navegador para los dialog, así que hay que sacarlo a mano. */
  .sheet {
    width: 100%;
    max-width: none;
    max-height: 90dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }
  .sheet-body {
    max-height: 90dvh;
    padding: 0 18px calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .player-now { flex: 1 1 90px; }
  .ctl { padding: 6px 4px; }
  .episode { gap: 10px; padding-inline: 16px; }
  .episode-artwork { width: 64px; height: 64px; }
  .episode-duration { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; }
}
