/**
 * styles.css — Login + menú principal BPW3.0
 *
 * Paleta logo: teal #45b1a2 · magenta #d11f7e
 * Menú (réplica Pantalla 2 BPW 2.5): bloques de color táctiles.
 */

:root {
  --teal: #45b1a2;
  --teal-dark: #38968a;
  --teal-soft: #e8f6f4;
  --magenta: #d11f7e;
  --bg: #ffffff;
  --text: #2a2a2a;
  --radius-btn: 999px;
  --shadow-btn: 0 4px 14px rgba(69, 177, 162, 0.35);
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  /* Hueco inferior para que los dialogs modeless no tapen el player */
  --bpw-player-bar-h: 11.5rem;
  --search-dialog-width: min(1120px, 88vw);
  --search-dialog-default-top: 5vh;
  --search-dialog-default-height: 90vh;

  /* Colores del menú principal (Pantalla 2) */
  --menu-grupos: #9fd38a;       /* verde claro */
  --menu-import: #3b6fd9;       /* azul */
  --menu-export: #e03a9a;       /* fucsia */
  --menu-music: #6ec6e8;        /* celeste */
  --menu-exercise: #2f9e8f;     /* verde azulado */
  --menu-video: #8e5a2b;        /* marrón cálido */
  --menu-about: #1f6b4a;        /* verde oscuro */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  min-height: 100dvh;
}

/* =========================================================================
   LOGIN
   ========================================================================= */

.login-screen {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2vw, 1.35rem);
  padding: clamp(0.75rem, 3vw, 2rem);
  padding-bottom: max(clamp(0.75rem, 3vw, 2rem), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #ffffff 0%, #e0f7fa 100%);
}

.login-header-wrapper {
  box-sizing: border-box;
  width: min(920px, 94vw);
  margin: 0 auto;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(0.45rem, 1.2vh, 0.85rem);
  min-width: 0;
}

.login-header {
  width: 100%;
  display: block;
  line-height: 0;
}

.login-logo {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

/* Desktop: achata el logo (deforma el aspect-ratio) para que el login quepa sin scroll */
@media (min-width: 1024px) {
  .login-screen {
    height: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
  }

  .login-logo {
    width: 80%;
    max-width: 900px;
    height: 45vh;
    max-height: 400px;
    margin-inline: auto;
    object-fit: fill;
  }
}

.credits {
  box-sizing: border-box;
  width: 100%;
  background: var(--teal-soft);
  border-radius: 8px;
  padding: clamp(0.5rem, 1.1vh, 0.8rem) 1.1rem;
  text-align: center;
  line-height: 1.4;
}

.credits p {
  margin: 0.1rem 0;
  font-size: clamp(0.72rem, 1.5vw, 0.92rem);
}

.credits-design {
  color: var(--teal);
  font-weight: 600;
}

.credits-videos {
  color: var(--magenta);
  font-weight: 600;
}

.credits a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.credits a:hover,
.credits a:focus-visible {
  opacity: 0.85;
}

.lang-buttons {
  box-sizing: border-box;
  width: min(920px, 94vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.5rem, 1.2vw, 0.85rem);
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 56px;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--teal);
  color: #fff;
  font-family: inherit;
  font-size: clamp(0.72rem, 1.35vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  user-select: none;
}

.lang-btn:hover {
  background: var(--teal-dark);
}

.lang-btn:active {
  transform: scale(0.97);
}

.lang-btn:focus-visible {
  outline: 3px solid var(--magenta);
  outline-offset: 3px;
}

.lang-btn .flag {
  font-size: 1.35rem;
  line-height: 1;
}

.lang-btn .lang-label {
  white-space: nowrap;
}

.login-status {
  min-height: 1.4em;
  margin: 0;
  text-align: center;
  color: var(--teal-dark);
  font-size: 1.05rem;
  font-weight: 700;
}

.login-status--error {
  color: var(--magenta);
}

.login-status--loading {
  color: var(--teal);
}

/* --- Diálogo de clave (táctil) ------------------------------------------- */

.clave-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 30, 35, 0.45);
}

.clave-dialog[hidden] {
  display: none !important;
}

.clave-panel {
  width: min(420px, 94vw);
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem 1.35rem 1.25rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.clave-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-align: center;
}

.clave-input {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--teal);
  border-radius: 12px;
  font-size: 1.15rem;
  font-family: inherit;
  text-align: center;
  letter-spacing: 0.06em;
}

.clave-input:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(209, 31, 126, 0.2);
}

.clave-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.clave-btn {
  min-height: 48px;
  border: none;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.clave-btn--cancel {
  background: #e8ecee;
  color: #445;
}

.clave-btn--submit {
  background: var(--teal);
  color: #fff;
}

.clave-btn:active {
  transform: scale(0.97);
}

/* =========================================================================
   MENÚ PRINCIPAL (Pantalla 2)
   ========================================================================= */

.main-menu {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.25rem, 3.5vh, 2.25rem);
  padding: clamp(1.25rem, 4vh, 2.5rem) clamp(1rem, 3vw, 2rem);
  padding-bottom: max(clamp(1rem, 3vh, 1.75rem), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #ffffff 0%, #e0f7fa 100%);
  box-sizing: border-box;
}

.menu-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease,
    background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  padding: 1rem;
  text-align: center;
  line-height: 1.25;
}

.menu-tile:hover {
  filter: brightness(1.05);
}

.menu-tile:active {
  transform: scale(0.985);
}

.menu-tile:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

.menu-tile__label {
  pointer-events: none;
  max-width: 95%;
}

/* --- Marca / logo --- */
.menu-brand {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0 0 0.25rem;
}

.menu-logo {
  display: block;
  width: auto;
  max-width: min(280px, 72vw);
  height: auto;
  margin: 0 auto 0.35rem;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* --- Landing: hero GRUPOS/CLASES --- */
.hero-section {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.menu-hero,
.menu-tile--grupos {
  flex: 0 1 auto;
  width: min(680px, 100%);
  min-height: clamp(180px, 34vh, 300px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: clamp(1.75rem, 5vw, 2.75rem) clamp(1.5rem, 4vw, 2.5rem);
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, #1abc9c 0%, #2ab5c0 60%, #c2468a 100%);
  color: #ffffff;
  box-shadow: 0 15px 35px rgba(26, 188, 156, 0.25);
  font-size: inherit;
  text-transform: none;
  letter-spacing: 0.01em;
}

.menu-hero:hover,
.menu-tile--grupos:hover {
  filter: none;
  transform: translateY(-8px);
  box-shadow: 0 22px 44px rgba(26, 188, 156, 0.32);
}

.menu-hero:active,
.menu-tile--grupos:active {
  transform: translateY(-3px) scale(0.995);
}

.menu-hero__label {
  pointer-events: none;
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(20, 40, 50, 0.2);
}

.menu-hero__subtitle {
  pointer-events: none;
  max-width: 28rem;
  margin: 0;
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.4;
  text-align: center;
  color: rgba(255, 255, 255, 0.94);
}

/* --- Landing: toolbar administrativa --- */
.admin-toolbar,
.menu-row {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 960px;
  margin: 0.35rem auto 0;
  min-height: 0;
}

.menu-admin-btn,
.admin-toolbar .menu-tile,
.menu-row .menu-tile {
  flex: 1 1 9.5rem;
  max-width: 11.5rem;
  min-height: 4.25rem;
  min-width: min(100%, 9rem);
  padding: 0.85rem 0.9rem 0.95rem;
  border: none;
  border-radius: 12px;
  border-bottom: 4px solid transparent;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  font-size: clamp(0.68rem, 1.35vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.3;
  text-transform: uppercase;
}

.menu-admin-btn:hover,
.admin-toolbar .menu-tile:hover,
.menu-row .menu-tile:hover {
  filter: brightness(1.06);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.menu-admin-btn:active,
.admin-toolbar .menu-tile:active,
.menu-row .menu-tile:active {
  transform: translateY(-1px) scale(0.99);
}

.menu-admin-btn .menu-tile__label,
.admin-toolbar .menu-tile__label {
  max-width: 100%;
  line-height: 1.3;
  color: inherit;
}

/* Colores sólidos (especificidad > .admin-toolbar .menu-tile) */
.admin-toolbar .menu-tile--import,
.menu-admin-btn.menu-tile--import {
  background: var(--menu-import);
  color: #ffffff;
  border-bottom-color: #2a55b8;
}

.admin-toolbar .menu-tile--export,
.menu-admin-btn.menu-tile--export {
  background: var(--menu-export);
  color: #ffffff;
  border-bottom-color: #b01f72;
}

.admin-toolbar .menu-tile--music,
.menu-admin-btn.menu-tile--music {
  background: var(--menu-music);
  color: #0a2f3d;
  border-bottom-color: #3a9fc4;
}

.admin-toolbar .menu-tile--exercise,
.menu-admin-btn.menu-tile--exercise {
  background: var(--menu-exercise);
  color: #ffffff;
  border-bottom-color: #217a6e;
}

.admin-toolbar .menu-tile--video,
.menu-admin-btn.menu-tile--video {
  background: var(--menu-video);
  color: #ffffff;
  border-bottom-color: #6a4120;
}

.admin-toolbar .menu-tile--about,
.menu-admin-btn.menu-tile--about {
  background: var(--menu-about);
  color: #ffffff;
  border-bottom-color: #144a34;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .lang-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .lang-btn:last-child {
    grid-column: 1 / -1;
    max-width: 50%;
    justify-self: center;
    width: 100%;
  }

  .menu-hero,
  .menu-tile--grupos {
    min-height: clamp(160px, 30vh, 260px);
  }

  .admin-toolbar,
  .menu-row {
    gap: 1rem;
  }
}

@media (max-width: 520px) {
  .lang-buttons {
    grid-template-columns: 1fr;
  }

  .lang-btn:last-child {
    grid-column: auto;
    max-width: none;
  }

  .lang-btn {
    min-height: 54px;
    font-size: 0.95rem;
  }

  .main-menu {
    justify-content: flex-start;
    gap: 1.15rem;
    padding: 1rem 0.85rem 1.25rem;
  }

  .menu-logo {
    max-width: min(220px, 70vw);
    margin-bottom: 0.15rem;
  }

  .menu-hero,
  .menu-tile--grupos {
    min-height: 150px;
    width: 100%;
    border-radius: 20px;
  }

  .menu-hero__label {
    font-size: 1.55rem;
  }

  .admin-toolbar,
  .menu-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .menu-admin-btn,
  .admin-toolbar .menu-tile,
  .menu-row .menu-tile {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 52px;
    font-size: 0.78rem;
    padding: 0.75rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lang-btn,
  .menu-tile,
  .menu-hero,
  .clave-btn {
    transition: none;
  }

  .menu-hero:hover,
  .menu-tile--grupos:hover,
  .menu-admin-btn:hover {
    transform: none;
  }
}

/* =========================================================================
   SHELL SPA — 3 áreas fijas (TOP / CENTER / BOTTOM)
   ========================================================================= */

.spa-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: #eef3f1;
  overflow: hidden;
}

.spa-shell[hidden] {
  display: none !important;
}

#view-login[hidden] {
  display: none !important;
}

/* Visibilidad condicional TOP / BOTTOM (ocultos en menú principal) */
.is-hidden {
  display: none !important;
}

.spa-shell--with-chrome {
  background: #eef3f1;
}

.spa-shell--menu-only {
  background: linear-gradient(180deg, #ffffff 0%, #e0f7fa 100%);
}

/* Overlay logout */
.logout-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 28, 32, 0.55);
  padding: 1.25rem;
}

.logout-overlay[hidden],
.logout-overlay.is-hidden {
  display: none !important;
}

.logout-overlay__msg {
  margin: 0;
  padding: 1.25rem 1.75rem;
  border-radius: 14px;
  background: #fff;
  color: var(--teal-dark);
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.25);
}

/* --- TOP: botones de búsqueda (TEXT vive en #searchModal) --- */
.top-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding: 0.55rem 0.75rem;
  background: #b8e0a8;
  color: #1a3d12;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 20;
}

.top-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
}

.top-btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0.4rem 0.65rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(0.65rem, 1.7vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

.top-btn:active {
  transform: scale(0.97);
}

.top-btn--music {
  background: #c2185b; /* magenta / fucsia oscuro */
}

.top-btn--ejer {
  background: #e67e22; /* naranja */
}

.top-btn--grp-ejer {
  background: #7b1fa2; /* morado / púrpura */
}

.top-btn--video {
  background: #8e5a2b; /* marrón — alineado con NUEVOS VIDEOS */
}

/* Modo de búsqueda activo */
.top-btn.is-search-active {
  box-shadow: inset 0 0 0 3px #111, 0 2px 8px rgba(0, 0, 0, 0.25);
  filter: brightness(1.08);
  transform: scale(1.02);
}

/* --- Utilidad + botones de la cuadrícula GRP (viven en <dialog>) --- */
.hidden {
  display: none !important;
}

.grid-grupos__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  width: 100%;
  height: 100%;
  padding: 0.5rem 0.4rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(1.05rem, 2.5vw, 1.28rem);
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: #0a1820;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.grid-grupos__btn:active {
  transform: scale(0.97);
}

.grid-grupos__btn:focus-visible {
  outline: 3px solid #111;
  outline-offset: -3px;
}

.grid-grupos__btn:nth-child(1) { background: #bcd9f0; }
.grid-grupos__btn:nth-child(2) { background: #a9cdec; }
.grid-grupos__btn:nth-child(3) { background: #9ec9e8; }
.grid-grupos__btn:nth-child(4) { background: #8fbfe6; }
.grid-grupos__btn:nth-child(5) { background: #c8e6c0; }
.grid-grupos__btn:nth-child(6) { background: #b7dfae; }
.grid-grupos__btn:nth-child(7) { background: #aad9a0; }
.grid-grupos__btn:nth-child(8) { background: #9dd493; }
.grid-grupos__btn:nth-child(9) { background: #fdf1b8; }
.grid-grupos__btn:nth-child(10) { background: #fbe89f; }
.grid-grupos__btn:nth-child(11) { background: #f9e086; }
.grid-grupos__btn:nth-child(12) { background: #f7d76d; }
.grid-grupos__btn:nth-child(13) { background: #e2e5e7; }
.grid-grupos__btn:nth-child(14) { background: #d5d9dc; }
.grid-grupos__btn:nth-child(15) { background: #c8cdd1; }
.grid-grupos__btn:nth-child(16) { background: #bbc1c6; }

/* =========================================================================
   OVERLAYS DETALLE (<dialog> — ejercicio / música / RT / CAMB)
   No desmontan la vista de clase ni tocan el reproductor global.
   ========================================================================= */

.overlay-dialog {
  padding: 0;
  border: none;
  border-radius: 14px;
  width: min(960px, 94vw);
  max-width: 94vw;
  height: min(880px, 90vh);
  max-height: 90vh;
  background: transparent;
  color: inherit;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

/*
 * DETALLES DE MÚSICA — tamaño amplio + scroll; puede tapar el player.
 * Apilamiento: z-index (dialogs > player por defecto; tras PRE-PLAY se invierte).
 */
.overlay-dialog--musica,
.overlay-dialog--musica[open],
.overlay-dialog--musica[open]:not(:modal),
.overlay-dialog--musica[open][data-bpw-modeless] {
  position: fixed;
  inset: unset;
  top: 5vh;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  margin: 5vh auto auto auto;
  z-index: 300;
  width: 80vw;
  max-width: 960px;
  height: 90vh;
  max-height: 90vh;
  overflow: hidden;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.overlay-dialog::backdrop {
  background: rgba(18, 28, 32, 0.55);
  backdrop-filter: blur(2px);
}

/* Modeless (show()): apilados por z-index, NUNCA top-layer */
.overlay-dialog[open]:not(:modal),
.overlay-dialog[open][data-bpw-modeless] {
  position: fixed;
  inset: unset;
  top: 5vh;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  margin: 5vh auto auto auto;
  z-index: 300;
  width: 80vw;
  max-width: 960px;
  height: 90vh;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

/* Encima de #searchModal (300); debajo de musica-rt (310) / música (320). */
.overlay-dialog--ejercicio[open]:not(:modal),
.overlay-dialog--ejercicio[open][data-bpw-modeless] { z-index: 305; }
.overlay-dialog--musica-rt[open]:not(:modal),
.overlay-dialog--musica-rt[open][data-bpw-modeless] { z-index: 310; }
.overlay-dialog--musica[open]:not(:modal),
.overlay-dialog--musica[open][data-bpw-modeless] { z-index: 320; }
.overlay-dialog--camb[open]:not(:modal),
.overlay-dialog--camb[open][data-bpw-modeless] { z-index: 330; }

.overlay-dialog__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  background: #f4f7f6;
  border-radius: 14px;
  overflow: hidden;
}

/* Scroll interno obligatorio (listas / ficha completa con PRE-PLAY) */
.overlay-dialog--musica .overlay-dialog__panel {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.overlay-dialog--musica .overlay-dialog__chrome {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
}

.overlay-dialog--musica .overlay-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  padding-bottom: 20px;
}

.overlay-dialog--musica .overlay-dialog__body > .musica-detalle-view,
.overlay-dialog--musica .musica-detalle-view {
  flex: 0 0 auto;
  height: auto;
  min-height: auto;
  max-height: none;
  overflow: visible;
  padding: 0.85rem 1rem 20px;
  padding-bottom: 20px;
}

.overlay-dialog__chrome {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: #e8eef0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.overlay-dialog__chrome-title {
  margin: 0;
  min-width: 0;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-weight: 800;
  color: #123a52;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.overlay-dialog__close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: #2c3e46;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.overlay-dialog__close:active {
  transform: scale(0.96);
}

.overlay-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.overlay-dialog__body > .ejercicio-detalle-view,
.overlay-dialog__body > .musica-detalle-view,
.overlay-dialog__body > .musica-rt-view {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.overlay-dialog__panel--camb {
  max-width: 480px;
  margin: 0 auto;
}

.overlay-dialog__camb-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.1rem 1.15rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay-dialog--camb {
  width: min(480px, 94vw);
  height: auto;
  max-height: 90vh;
}

@media (max-width: 900px) {
  .overlay-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .overlay-dialog__panel {
    border-radius: 0;
  }

  .overlay-dialog--camb {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
  }

  .overlay-dialog__panel--camb {
    max-width: none;
    margin: 0;
  }

  .overlay-dialog[open]:not(:modal),
  .overlay-dialog[open][data-bpw-modeless] {
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    transform: none;
    margin: 0 auto auto auto;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }

  .overlay-dialog--musica,
  .overlay-dialog--musica[open],
  .overlay-dialog--musica[open]:not(:modal),
  .overlay-dialog--musica[open][data-bpw-modeless] {
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    transform: none;
    margin: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    border-radius: 0;
  }

  .overlay-dialog--musica .overlay-dialog__panel {
    max-height: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 0;
  }

  .overlay-dialog--musica .overlay-dialog__body,
  .overlay-dialog--musica .musica-detalle-view {
    overflow: visible;
    height: auto;
    max-height: none;
    padding-bottom: 20px;
  }

  .overlay-dialog--musica .musica-detalle-view {
    padding: 0.85rem 1rem 20px;
  }
}

/* =========================================================================
   MODALES DE BÚSQUEDA (<dialog> — MUSIC / EJER / GRP)
   Overlay nativo: no cambian el hash ni sustituyen #content-area / #player-bar.
   ========================================================================= */

.search-dialog {
  padding: 0;
  border: none;
  border-radius: 14px;
  width: var(--search-dialog-width);
  max-width: 88vw;
  height: var(--search-dialog-default-height);
  max-height: var(--search-dialog-default-height);
  background: transparent;
  color: inherit;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.search-dialog::backdrop {
  background: rgba(18, 28, 32, 0.55);
  backdrop-filter: blur(2px);
}

/* Búsqueda: alto por defecto tapa el player; tamaño personalizable con ratón */
.search-dialog[open],
.search-dialog[open]:not(:modal),
.search-dialog[open][data-bpw-modeless] {
  position: fixed;
  inset: unset;
  top: var(--search-dialog-default-top);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  margin: 0;
  z-index: 300;
  width: var(--search-dialog-width);
  max-width: 88vw;
  height: var(--search-dialog-default-height);
  max-height: var(--search-dialog-default-height);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.search-dialog[open].search-dialog--sized,
.search-dialog[open].search-dialog--sized:not(:modal),
.search-dialog[open].search-dialog--sized[data-bpw-modeless] {
  transform: none;
  max-width: none;
  max-height: none;
}

/* ELEGIR MÚSICA LIBREMENTE desde ficha: lista delante del ejercicio (305). */
.search-dialog.search-dialog--front[open],
.search-dialog.search-dialog--front[open]:not(:modal),
.search-dialog.search-dialog--front[open][data-bpw-modeless] {
  z-index: 308;
}

.search-dialog__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  background: #f4f7f6;
  border-radius: 14px;
  overflow: hidden;
}

.search-modal__panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.search-dialog[open] .search-dialog__panel,
.search-dialog[open][data-bpw-modeless] .search-dialog__panel {
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.search-dialog__header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding: 0.75rem 0.85rem;
  background: #e8eef0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: default;
}

/* Asas de redimensionado (ratón / táctil) */
.search-dialog__resize-handle {
  position: absolute;
  z-index: 6;
  touch-action: none;
  user-select: none;
}

.search-dialog__resize-handle--e {
  top: 3.25rem;
  right: 0;
  bottom: 1.1rem;
  width: 10px;
  cursor: ew-resize;
}

.search-dialog__resize-handle--s {
  left: 1.1rem;
  right: 1.1rem;
  bottom: 0;
  height: 10px;
  cursor: ns-resize;
}

.search-dialog__resize-handle--se {
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  border-bottom-right-radius: 14px;
}

.search-dialog__resize-handle--se::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(44, 62, 70, 0.45);
  border-bottom: 2px solid rgba(44, 62, 70, 0.45);
  pointer-events: none;
}

.search-dialog.is-resizing,
.search-dialog.is-resizing * {
  cursor: inherit !important;
  user-select: none !important;
}

.search-dialog__panel--grp .search-dialog__header {
  grid-template-columns: 1fr auto;
}

.search-dialog__title {
  margin: 0;
  min-width: 0;
}

.search-dialog__subtitle {
  margin: 0 0 0.35rem;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  font-weight: 800;
  color: #123a52;
}

.search-dialog__close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: #2c3e46;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.search-dialog__close:active {
  transform: scale(0.96);
}

.search-dialog__back {
  flex: 0 0 auto;
  align-self: center;
  min-height: 44px;
  margin: 0;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: #9ec9e8;
  color: #123a52;
  font-family: inherit;
  font-size: clamp(0.68rem, 1.3vw, 0.8rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.search-modal__grp-back[hidden],
.search-modal__grp-back.is-hidden {
  display: none !important;
}

.search-dialog__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0.35rem 0.65rem 0.85rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
}

.search-dialog__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(72px, 1fr));
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0.65rem 0.65rem;
  padding: 0.35rem;
  background: #dfe8e4;
  border-radius: 10px;
}

.search-dialog__grid[hidden],
.search-dialog__grid.is-hidden {
  display: none !important;
}

.search-dialog__grp-lista {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 0.65rem 0.65rem;
  padding: 0.5rem;
  background: #fff;
  border-radius: 10px;
  box-sizing: border-box;
}

.search-dialog__grp-lista[hidden] {
  display: none !important;
}

/* --- #searchModal: TEXT + resultados / grupos --- */
.search-modal__text-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem 0.35rem;
  background: #f4f7f6;
}

.search-modal__text-row .search-modal__input,
.search-modal__text-row #search-input {
  flex: 1 1 auto;
  min-width: 0;
}

.search-modal__text-row[hidden],
.search-modal__text-row.is-hidden {
  display: none !important;
}

.search-modal__text-label {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #123a52;
}

.search-modal__input,
#searchModal #search-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #9ec9e8;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.35;
  color: #333333;
  caret-color: #333333;
  background-color: #ffffff;
  -webkit-text-fill-color: #333333;
  box-sizing: border-box;
}

.search-modal__input:focus,
#searchModal #search-input:focus {
  outline: 2px solid #45b1a2;
  outline-offset: 1px;
  color: #333333;
  caret-color: #333333;
  background-color: #ffffff;
  -webkit-text-fill-color: #333333;
}

.search-modal__results {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-modal__results[hidden] {
  display: none !important;
}

.search-modal__results .search-dialog__list {
  flex: 1 1 auto;
}

.search-modal__results .search-dialog__list[hidden] {
  display: none !important;
}

.search-modal__groups {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-modal__groups[hidden] {
  display: none !important;
}

.search-modal__header {
  grid-template-columns: 1fr auto auto;
}

@media (max-width: 900px) {
  .search-modal__text-row {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .search-modal__header {
    grid-template-columns: 1fr;
  }

  .search-modal__header .musica-search-btn--alph,
  .search-modal__header .search-dialog__close {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .search-dialog {
    width: min(1120px, 94vw);
    max-width: 94vw;
    height: var(--search-dialog-default-height);
    max-height: var(--search-dialog-default-height);
    border-radius: 12px;
    margin: 0;
  }

  .search-dialog[open]:not(.search-dialog--sized),
  .search-dialog[open]:not(.search-dialog--sized):not(:modal),
  .search-dialog[open]:not(.search-dialog--sized)[data-bpw-modeless] {
    top: var(--search-dialog-default-top);
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    margin: 0;
    width: min(1120px, 94vw);
    max-width: 94vw;
    min-height: 0;
    height: var(--search-dialog-default-height);
    max-height: var(--search-dialog-default-height);
    border-radius: 12px;
  }

  .search-dialog__panel {
    border-radius: 12px;
  }

  .search-dialog__header {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .search-dialog__header .musica-search-btn--alph {
    width: 100%;
  }

  .search-dialog__close {
    width: 100%;
  }

  .search-dialog__panel--grp .search-dialog__header {
    grid-template-columns: 1fr auto;
  }

  .search-dialog__panel--grp .search-dialog__close {
    width: 44px;
  }

  .search-dialog__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(8, minmax(64px, auto));
  }

  .grid-grupos__btn {
    min-height: 64px;
  }
}

/* --- CENTER: scroll; azul claro en vistas con chrome --- */
.content-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem;
  background: transparent;
}

.spa-shell--with-chrome .content-area {
  background: #d4ebf7; /* azul claro (misma paleta que lista de grupos) */
}

/* En detalle de clase el scroll vive en .ejercicios-grid, no en CENTER */
.content-area:has(.ejercicios-view) {
  overflow: hidden;
}

.content-area:has(.ejercicio-detalle-view) {
  overflow: hidden;
}

.content-area:has(.musica-rt-view) {
  overflow: hidden;
}

.content-area:has(.musica-search-view) {
  overflow: hidden;
}

.content-area:has(.ejercicio-search-view) {
  overflow: hidden;
}

.content-area:has(.musica-detalle-view) {
  /* El scroll vive en .musica-detalle-view (metadatos + botones) */
  overflow: hidden;
}

/* Menú embebido dentro del CENTER */
.main-menu--embedded {
  min-height: 100%;
  height: 100%;
  gap: clamp(1.1rem, 3vh, 2rem);
  padding: clamp(1rem, 3vh, 1.75rem) clamp(0.75rem, 2.5vw, 1.5rem);
  padding-bottom: max(clamp(0.85rem, 2.5vh, 1.5rem), env(safe-area-inset-bottom));
  background: transparent;
  justify-content: center;
}

.main-menu--embedded .menu-tile--grupos,
.main-menu--embedded .menu-hero {
  min-height: clamp(160px, 32vh, 280px);
}

.content-area:has(.main-menu) {
  background: transparent;
  padding: 0;
}

/* --- Vista GRUPOS (ancho completo) --- */
.grupos-view {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 100%;
  flex: 1 1 auto;
}

.grupos-toolbar,
.cabecera-grupos {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0.35rem 0;
  box-sizing: border-box;
}

.grupos-toolbar__title {
  flex: 1 1 auto;
  margin: 0;
  text-align: center;
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  font-weight: 800;
  font-style: italic;
  color: #12304a;
  letter-spacing: 0.02em;
  min-width: 10rem;
}

.grupos-toolbar__right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.grupo-action {
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(0.68rem, 1.4vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.grupo-action:active {
  transform: scale(0.97);
}

.grupo-action--crear {
  background: #2a9d8f; /* cerceta / teal */
}

.grupo-action--rename {
  background: #f48fb1; /* rosa claro */
  color: #4a1028;
}

.grupo-action--elim {
  background: #d81b60; /* fucsia / magenta */
}

.grupos-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  box-sizing: border-box;
}

.grupo-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
  padding: 0.75rem 1rem;
  background: #c6e3f4;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-weight: 700;
  color: #12304a;
  transition: background-color 0.15s ease;
}

.grupo-item:nth-child(even) {
  background: #b9daf0;
}

@media (hover: hover) {
  .grupo-item:nth-child(odd):not(.grupo-item--empty):hover {
    background: #adcfe8;
  }

  .grupo-item:nth-child(even):not(.grupo-item--empty):hover {
    background: #a1c8e3;
  }
}

.grupo-item:active {
  transform: scale(0.99);
}

.grupo-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.grupo-item--empty {
  background: #b8d4e8;
  color: #2a5070;
  cursor: default;
  justify-content: center;
  grid-template-columns: 1fr;
  text-align: center;
  font-weight: 600;
  font-style: italic;
}

.grupo-item__num {
  font-size: 1.15rem;
  min-width: 1.5rem;
}

.grupo-item__title {
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grupo-item__meta {
  font-size: 0.85rem;
  opacity: 0.92;
  white-space: nowrap;
}

/* --- Lista de ejercicios filtrada por grupo (cuadrícula GRP EJER/EXER) --- */
.grupo-ejer-lista-view {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
}

.grupo-ejer-lista__toolbar {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
}

.grupo-ejer-lista__title {
  margin: 0;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  font-weight: 800;
  text-transform: uppercase;
  color: #1a3d12;
  line-height: 1.35;
}

.grupo-ejer-lista {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.grupo-ejer-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.7rem 1rem;
  background: #d4e8f7;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-weight: 700;
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  color: #123a52;
  text-align: left;
  line-height: 1.35;
}

.grupo-ejer-item__ord {
  flex: 0 0 auto;
  min-width: 2.4em;
  font-weight: 800;
  color: #1a4a6e;
  font-variant-numeric: tabular-nums;
}

.grupo-ejer-item__label {
  flex: 1 1 auto;
  min-width: 0;
}

.ejercicio-list-label {
  display: inline;
  white-space: nowrap;
}

.ejercicio-list-label__ord {
  font-weight: 800;
  color: #1e6b58;
  font-variant-numeric: tabular-nums;
  margin-right: 0.2em;
}

.ejercicio-list-label__name {
  font-weight: inherit;
}

.ejercicio-list-label__sep {
  color: #5a8f80;
  font-weight: 600;
  padding: 0 0.28em;
  opacity: 0.85;
}

.ejercicio-list-label__fase {
  font-weight: 800;
  color: #0f766e;
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
  text-align: center;
}

.ejercicio-list-label__int {
  font-weight: 800;
  color: #0f766e;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: center;
}

.grupo-ejer-item:nth-child(even) {
  background: #bddaf0;
}

.grupo-ejer-item:active {
  transform: scale(0.995);
}

.grupo-ejer-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.grupo-ejer-item--empty {
  background: rgba(255, 255, 255, 0.55);
  color: #445;
  cursor: default;
  text-align: center;
  font-weight: 600;
  font-style: italic;
}

/* --- BOTTOM: reproductor (por debajo de modales salvo bpw-player-front) --- */
.player-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem max(0.65rem, env(safe-area-inset-bottom));
  background: #b8e0a8;
  color: #1a3d12;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 100;
}

/*
 * Z-INDEX SWAP:
 * - Por defecto: dialogs (300+) por encima del player (100).
 * - Tras PRE-PLAY (html.bpw-player-front): player (10000) por encima;
 *   dialogs quedan detrás, atenuados, pero siguen recibiendo clics para restaurar.
 */
html.bpw-player-front .player-bar,
html.bpw-player-front #player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000 !important;
  pointer-events: auto !important;
  isolation: isolate;
  background: #b8e0a8;
  opacity: 1;
  filter: none;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.28);
}

/* Tras PRE-PLAY: el overlay no intercepta clics fuera del panel (pasa al player). */
html.bpw-player-front .search-dialog[open],
html.bpw-player-front .overlay-dialog[open] {
  z-index: 200 !important;
  opacity: 0.72;
  filter: brightness(0.88);
  pointer-events: none;
}

html.bpw-player-front .search-dialog[open] .search-dialog__panel,
html.bpw-player-front .search-dialog[open] .search-modal__panel,
html.bpw-player-front .overlay-dialog[open] .overlay-dialog__panel {
  pointer-events: auto;
}

.player-bar__now {
  margin: 0;
  min-width: 0;
  width: 100%;
  text-align: center;
}

/* Título grande centrado (pista precargada / en reproducción + duración) */
.player-bar__title {
  display: block;
  width: 100%;
  text-align: center;
  font-size: clamp(1.15rem, 2.8vw, 1.65rem);
  line-height: 1.25;
  color: #12352f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.player-bar__progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}

/* Fondo base; el relleno lo pinta JS con linear-gradient en style.background */
.player-bar__progress {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 14px;
  margin: 0;
  border-radius: 999px;
  border: none;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
  background: linear-gradient(to right, #1b6b5f 0%, #cfe8c4 0%);
}

.player-bar__progress::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background: transparent;
}

.player-bar__progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1f4d44;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.player-bar__progress::-moz-range-track {
  height: 14px;
  border-radius: 999px;
  background: transparent;
  border: none;
}

.player-bar__progress::-moz-range-progress {
  /* Firefox nativo; el linear-gradient JS cubre el resto de navegadores */
  height: 14px;
  border-radius: 999px;
  background: #1b6b5f;
}

.player-bar__progress::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1f4d44;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

/* Solo tiempo actual (la duración total va en el título) */
.player-bar__time {
  flex: 0 0 auto;
  font-size: clamp(1.25rem, 3.2vw, 1.85rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #0d3a32;
  white-space: nowrap;
  line-height: 1;
  min-width: 5.5ch;
  text-align: right;
}

/* Controles de reproducción + volumen */
.player-bar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  width: 100%;
}

.player-bar__controls-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.player-bar__volume {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 1 160px;
  min-width: 110px;
  max-width: 200px;
  padding: 0.15rem 0.35rem;
}

.player-bar__volume-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0d3a32;
}

.player-bar__volume-range {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
  accent-color: #2a9d8f;
}

.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  flex: 1 1 auto;
  min-width: 44px;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  color: #1a3d12;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.player-btn img {
  display: block;
  pointer-events: none;
}

.player-btn--text {
  width: auto;
  flex: 1 1 auto;
  font-size: clamp(0.62rem, 1.35vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 8px 12px;
  white-space: nowrap;
}

.player-btn--play {
  background: #1e6fdb;
  color: #fff;
}

.player-btn--pause,
.player-btn--stop,
.player-btn--repeat {
  background: #b3d9f2;
  color: #0d47a1;
  border-color: #7eb6d9;
}

.player-btn--play-exer {
  background: #7a4fcf;
  color: #fff;
}

.player-btn--play-class {
  background: #2a9d8f;
  color: #fff;
}

.player-btn--voice {
  background: #b0bec5;
  color: #455a64;
  min-width: 52px;
  border-color: #90a4ae;
}

.player-btn--voice.is-listening {
  background: #c62828;
  color: #fff;
  border-color: #8e0000;
  box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.35);
}

.player-btn--voice.is-armed {
  background: #c47b17;
  color: #fff;
  border-color: #c47b17;
  box-shadow: 0 0 0 2px rgba(196, 123, 23, 0.35);
}

.player-btn--voice.is-denied {
  background: #8e0000;
  color: #fff;
  border-color: #8e0000;
}

.player-btn--voice.is-capturing {
  animation: voice-capture-blink 0.5s ease-in-out 2;
}

@keyframes voice-capture-blink {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.35);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 5px rgba(255, 82, 82, 0.45);
  }
}

.player-bar__voice-status {
  display: none;
}

.player-btn.is-active {
  outline: 2px solid #0d47a1;
  outline-offset: 1px;
}

.player-btn:active {
  transform: scale(0.96);
}

/* Feedback activo en controles del reproductor (NO aplica a PRE-PLAY de la ficha) */
.player-btn.btn-active-red {
  background: #c62828 !important;
  color: #fff !important;
  border-color: #8e0000 !important;
  outline: none;
}

@media (max-width: 720px) {
  :root {
    --bpw-player-bar-h: 14.5rem;
  }

  .player-bar__progress-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .player-bar__time {
    text-align: center;
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    min-width: 5.5ch;
  }

  .player-bar__controls {
    flex-direction: column;
    align-items: stretch;
  }

  .player-bar__volume {
    max-width: none;
    flex: 1 1 auto;
    width: 100%;
  }

  .player-bar__controls-left {
    width: 100%;
    justify-content: center;
  }
}

/* =========================================================================
   VISTA LISTA DE CLASES
   ========================================================================= */

.clases-view {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.clases-toolbar {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.15rem;
}

.clases-toolbar__title {
  margin: 0;
  text-align: center;
  font-size: clamp(0.85rem, 2.2vw, 1.15rem);
  font-weight: 800;
  color: #1f4d44;
  letter-spacing: 0.02em;
  line-height: 1.25;
  padding: 0 0.35rem;
}

.clase-action {
  min-height: 44px;
  padding: 0.4rem 0.7rem;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(0.65rem, 1.3vw, 0.8rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.clase-action:active {
  transform: scale(0.97);
}

.clase-action--crear {
  background: #45b1a2; /* turquesa */
}

.clase-action--duplic {
  background: #d11f7e; /* magenta */
}

.clase-action--import {
  background: #7a4fcf; /* morado */
}

.clase-action--rename {
  background: #3b6fd9; /* azul */
}

.clase-action--elim {
  background: #c0392b; /* rojo */
}

.clases-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.clase-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 56px;
  padding: 0.75rem 1rem;
  background: #b8ddd6;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-weight: 700;
  color: #12352f;
}

.clase-item:nth-child(even) {
  background: #a8d4cb;
}

.clase-item:active {
  transform: scale(0.99);
}

.clase-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.clase-item--empty {
  background: #dfe8e4;
  color: #556;
  cursor: default;
  justify-content: center;
  grid-template-columns: 1fr;
  text-align: center;
  font-weight: 600;
}

.clase-item__num {
  font-size: 1.15rem;
  min-width: 1.5rem;
}

.clase-item__title {
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clase-item__meta {
  font-size: 0.85rem;
  opacity: 0.92;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .top-bar {
    padding: 0.5rem;
  }

  .top-btn {
    font-size: 0.7rem;
    padding: 0.35rem 0.55rem;
  }

  .clases-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .clases-toolbar__title {
    grid-column: 1 / -1;
    order: -1;
    margin-bottom: 0.15rem;
  }

  .clase-item {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .clase-item__meta {
    grid-column: 2;
  }

  .grupo-item {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .grupo-item__meta {
    grid-column: 2;
  }
}

/* Vista GRUPOS: cabecera apilada en móvil / tablet vertical */
@media (max-width: 768px) {
  .grupos-view {
    padding: 10px 12px;
  }

  .grupos-toolbar,
  .cabecera-grupos {
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
  }

  .grupos-toolbar__title {
    order: -1;
    width: 100%;
    text-align: center;
  }

  .grupos-toolbar > .grupo-action--crear,
  .cabecera-grupos > .grupo-action--crear {
    width: 100%;
    min-height: 48px;
  }

  .grupos-toolbar__right {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    gap: 8px;
  }

  .grupos-toolbar__right .grupo-action {
    flex: none;
    width: 100%;
    min-height: 48px;
  }
}

/* =========================================================================
   VISTA DETALLE CLASE / LISTA DE EJERCICIOS
   ========================================================================= */

.ejercicios-view {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.ejercicios-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.3rem 0.1rem;
  min-width: 0;
}

.ejercicios-toolbar__title {
  margin: 0;
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.85rem, 2.1vw, 1.1rem);
  font-weight: 800;
  color: #12304a;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.ejercicios-toolbar__actions {
  display: flex;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 0.4rem;
}

.ejercicio-action {
  min-height: 42px;
  padding: 0.35rem 0.7rem;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(0.65rem, 1.25vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.ejercicio-action:active {
  transform: scale(0.97);
}

.ejercicio-action--curva {
  background: #3b6fd9;
}

.ejercicio-action--nota {
  background: #7a4fcf;
}

.ejercicio-action--exportar {
  background: #2a9d8f;
}

.ejercicio-action--descargar {
  background: #c0392b;
}

.ejercicios-toolbar__duration {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  min-height: 42px;
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  background: #fff8e1;
  border: 2px solid #c79100;
  color: #5d4200;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ejercicios-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ejercicios-grid__head,
.ejercicios-grid__row {
  display: grid;
  grid-template-columns: minmax(10rem, 1.15fr) repeat(3, minmax(8rem, 1fr));
  gap: 1px;
  background: #7eb0cf;
  flex: 0 0 auto;
}

.ejercicios-grid__head {
  position: sticky;
  top: 0;
  z-index: 3;
}

.ejercicios-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 34px;
  padding: 0.22rem 0.5rem;
  margin: 0;
  border: none;
  border-radius: 0;
  font-family: inherit;
  font-size: clamp(0.72rem, 1.35vw, 0.88rem);
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  color: #12304a;
  background: #c6e3f4;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  width: 100%;
  overflow: hidden;
}

.ejercicios-cell--head {
  cursor: default;
  background: #4a8ab8;
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.7rem, 1.3vw, 0.82rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-items: center;
  min-height: 32px;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.ejercicios-grid__row:nth-child(even) .ejercicios-cell:not(.ejercicios-cell--head) {
  background: #b9daf0;
}

.ejercicios-cell--ejer {
  font-weight: 700;
}

.ejercicios-cell--music:disabled {
  cursor: default;
  opacity: 0.55;
}

.ejercicios-cell:not(.ejercicios-cell--head):not(:disabled):hover {
  filter: brightness(1.05);
}

.ejercicios-cell:not(.ejercicios-cell--head):not(:disabled):active {
  filter: brightness(0.96);
}

.ejercicios-cell:focus-visible {
  outline: 3px solid #4a8ab8;
  outline-offset: -3px;
  z-index: 1;
}

/* Una línea; si no cabe, marquee al hover/focus (ver .is-overflow + JS) */
.ejercicios-cell__text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.ejercicios-cell__marquee {
  display: inline-block;
  white-space: nowrap;
  max-width: none;
  transform: translateX(0);
}

.ejercicios-cell.is-overflow:hover .ejercicios-cell__marquee,
.ejercicios-cell.is-overflow:focus-visible .ejercicios-cell__marquee {
  animation: ejercicios-cell-marquee var(--marquee-duration, 4s) linear forwards;
}

@keyframes ejercicios-cell-marquee {
  0%,
  8% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(var(--marquee-distance, 0));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ejercicios-cell.is-overflow:hover .ejercicios-cell__marquee,
  .ejercicios-cell.is-overflow:focus-visible .ejercicios-cell__marquee {
    animation: none;
  }
}

.ejercicios-grid__empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: #2a5070;
  font-weight: 600;
  background: #d4ebf7;
}

/* Drag & Drop — reordenar filas de la clase */
.ejercicios-grid__row[draggable='true'] {
  cursor: grab;
  touch-action: none;
}

.ejercicios-grid__row[draggable='true']:active {
  cursor: grabbing;
}

.ejercicios-grid__row.is-dragging {
  opacity: 0.45;
}

.ejercicios-grid__row.is-drag-over {
  outline: 2px dashed #4a8ab8;
  outline-offset: -2px;
}

@media (max-width: 900px) {
  .ejercicios-toolbar {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }

  .ejercicios-toolbar__title {
    flex: 0 1 auto;
    width: 100%;
  }

  .ejercicios-toolbar__actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .ejercicio-action,
  .ejercicios-toolbar__duration {
    flex: 1 1 auto;
  }

  .ejercicios-grid__head,
  .ejercicios-grid__row {
    grid-template-columns: 1fr;
  }

  .ejercicios-cell--head {
    display: none;
  }

  .ejercicios-grid__row {
    margin-bottom: 0.45rem;
    border-radius: 8px;
    overflow: hidden;
    gap: 0;
  }

  .ejercicios-cell--ejer::before,
  .ejercicios-cell--music[data-zone='musica1']::before,
  .ejercicios-cell--music[data-zone='musica2']::before,
  .ejercicios-cell--music[data-zone='musica3']::before {
    display: block;
    content: attr(data-col-label);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    opacity: 0.75;
    margin-bottom: 0.08rem;
    white-space: nowrap;
  }

  .ejercicios-cell {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding-top: 0.28rem;
    padding-bottom: 0.28rem;
  }
}

/* Encima del reproductor: ficha de ejercicio */
.overlay-dialog--ejercicio[open]:not(:modal),
.overlay-dialog--ejercicio[open][data-bpw-modeless] {
  position: fixed;
  inset: unset;
  top: 0.75vh;
  left: 50%;
  right: auto;
  bottom: calc(var(--bpw-player-bar-h, 11.5rem) + 0.75rem);
  transform: translateX(-50%);
  margin: 0.75vh auto auto auto;
  width: min(920px, 92vw);
  max-width: 92vw;
  height: auto;
  max-height: calc(100dvh - var(--bpw-player-bar-h, 11.5rem) - 0.75vh - 1.25rem);
  overflow: hidden;
}

.overlay-dialog--ejercicio .overlay-dialog__panel {
  background: linear-gradient(165deg, #ecf9f6 0%, #d4f0ea 42%, #b8e6dc 100%);
  border: 1px solid rgba(69, 177, 162, 0.42);
  box-shadow: 0 14px 44px rgba(18, 48, 45, 0.16);
  max-height: 100%;
  height: 100%;
  min-height: 0;
}

.overlay-dialog--ejercicio .overlay-dialog__body {
  padding-bottom: max(0.35rem, calc(var(--bpw-player-bar-h, 11.5rem) * 0.15));
  background: rgba(196, 236, 228, 0.35);
}

.overlay-dialog--ejercicio .overlay-dialog__chrome {
  background: rgba(196, 236, 228, 0.96);
  border-bottom: 1px solid rgba(69, 177, 162, 0.32);
  padding: 0.45rem 0.75rem;
}

/* =========================================================================
   PANTALLA DETALLE DE EJERCICIO — 5 filas a ancho completo (.ejercicio-grid)
   ========================================================================= */

.ejercicio-detalle-view {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  background: rgba(196, 236, 228, 0.62);
  border-radius: 10px;
  border: 1px solid rgba(69, 177, 162, 0.22);
}

.ejercicio-grid {
  display: grid;
  width: 100%;
  gap: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-content: start;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto auto auto;
}

/* Modo consulta: título + info + selección (sin pistas ni acciones) */
.ejercicio-detalle-view--consult .ejercicio-grid {
  grid-template-rows: auto auto auto;
}

.ejercicio-grid__row {
  display: grid;
  width: 100%;
  gap: 8px;
  box-sizing: border-box;
  min-width: 0;
}

/* Línea 1 — título centrado 100% */
.ejercicio-grid__row--titulo {
  grid-template-columns: 1fr;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 1px 5px rgba(18, 48, 45, 0.1);
}

.ejercicio-grid__title {
  margin: 0;
  text-align: center;
  font-size: clamp(0.88rem, 2.2vw, 1.15rem);
  font-weight: 800;
  text-transform: uppercase;
  color: #1a3d12;
  line-height: 1.3;
  letter-spacing: 0.02em;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Línea 2 — VER DESCRIPCION | MATICES | VER VIDEO */
.ejercicio-grid__row--info {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Línea 3 — ELEGIR MUSICA RT/CIMEB | ELEGIR MUSICA LIBREMENTE */
.ejercicio-grid__row--seleccion {
  grid-template-columns: 1fr 1fr;
}

/* Línea 4 — MUSIC 1 | MUSIC 2 | MUSIC 3 (celda vacía si no hay pista) */
.ejercicio-grid__row--pistas {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Línea 5 — BORRAR | spacer | GUARDAR */
.ejercicio-grid__row--acciones {
  grid-template-columns: 1fr 1fr 1fr;
}

.ejercicio-grid__cell--empty,
.ejercicio-grid__cell--spacer {
  min-height: 44px;
  pointer-events: none;
}

.ej-det-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(0.7rem, 1.55vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.25;
  color: #111;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ej-det-btn:active {
  transform: scale(0.97);
}

.ej-det-btn:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.ej-det-btn--desc { background: #bcd9f0; }
.ej-det-btn--matices { background: #c8e6c0; }
.ej-det-btn--video { background: #f9e086; }
.ej-det-btn--music-rt { background: #e2c4f0; }
.ej-det-btn--music-libre { background: #f5c6aa; }

.ej-det-btn--pista {
  background: #d4e8f7;
  text-transform: none;
  font-weight: 700;
  justify-content: flex-start;
  text-align: left;
}

.ejercicio-grid__row--pistas > .ej-det-btn--pista:nth-of-type(2) {
  background: #bddaf0;
}

.ejercicio-grid__row--pistas > .ej-det-btn--pista:nth-of-type(3) {
  background: #a8cce8;
}

/* BORRAR: rojo/granate — GUARDAR: azul */
.ej-det-btn--borrar {
  background: #8b1e2d;
  color: #fff;
}

.ej-det-btn--guardar {
  background: #2a6fdb;
  color: #fff;
  opacity: 0.7;
}

.ej-det-btn--guardar.is-dirty {
  opacity: 1;
  box-shadow: 0 0 0 2px #0d3a7a, 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* -------------------------------------------------------------------------
   Móviles / tablet vertical — apilar filas 2–4; acciones sin spacer
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ejercicio-grid {
    gap: 8px;
    padding: 8px 10px;
  }

  .ejercicio-grid__row {
    gap: 8px;
  }

  .ejercicio-grid__row--titulo {
    padding: 0.4rem 0.55rem;
  }

  /* Líneas 2, 3 y 4: un botón por fila, ancho completo */
  .ejercicio-grid__row--info,
  .ejercicio-grid__row--seleccion,
  .ejercicio-grid__row--pistas {
    grid-template-columns: 1fr;
  }

  /* Celdas vacías de pistas: no ocupan espacio en móvil */
  .ejercicio-grid__cell--empty {
    display: none;
  }

  /* Modo consulta: no dejar hueco del spacer central (MATICES) */
  .ejercicio-detalle-view--consult .ejercicio-grid__row--info .ejercicio-grid__cell--spacer {
    display: none;
  }

  /* Línea 5: sin spacer; BORRAR | GUARDAR en 2 columnas */
  .ejercicio-grid__row--acciones {
    grid-template-columns: 1fr 1fr;
  }

  .ejercicio-grid__cell--spacer {
    display: none;
  }

  /* Ergonomía táctil */
  .ej-det-btn {
    min-height: 40px;
    padding: 0.4rem 0.5rem;
    font-size: clamp(0.66rem, 1.4vw, 0.82rem);
  }

  .ej-det-btn--pista {
    min-height: 46px;
    padding: 0.5rem 0.55rem;
  }
}

/* Teléfonos estrechos: acciones apiladas a 100% de ancho */
@media (max-width: 420px) {
  .ejercicio-grid {
    gap: 6px;
    padding: 6px 8px;
  }

  .ejercicio-grid__row {
    gap: 6px;
  }

  .ejercicio-grid__row--acciones {
    grid-template-columns: 1fr;
  }

  .ej-det-btn {
    min-height: 44px;
  }
}

/* =========================================================================
   LISTA MÚSICAS RT/CIMEB (ELEGIR MUSICA DEL EJERCICIO)
   ========================================================================= */

.musica-rt-view {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem 0.5rem;
}

.musica-rt-toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  background: #9ec9e8;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.musica-rt-toolbar__title {
  margin: 0;
  text-align: center;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  color: #123a52;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.musica-rt-btn {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.musica-rt-btn:active {
  transform: scale(0.97);
}

.musica-rt-btn--volver {
  background: #5a7a92;
  color: #fff;
}

.musica-rt-btn--alph {
  background: #e89ab8;
  color: #4a1030;
}

.musica-rt-btn--alph.is-active {
  background: #d4588a;
  color: #fff;
  box-shadow: 0 0 0 2px #8b1e4a, 0 2px 6px rgba(0, 0, 0, 0.15);
}

.musica-rt-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0.25rem 0.15rem 0.5rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
  box-sizing: border-box;
}

.musica-rt-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  margin: 0;
  padding: 0.85rem 1.1rem;
  background: #e8f2fa;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #111;
  text-align: left;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.musica-rt-item__ord {
  flex: 0 0 auto;
  min-width: 2.4em;
  font-weight: 800;
  color: #1a4a6e;
  font-variant-numeric: tabular-nums;
}

.musica-rt-item--first .musica-rt-item__ord {
  color: inherit;
}

.musica-rt-item__label {
  flex: 1 1 auto;
  min-width: 0;
}

.musica-rt-item__label.ejercicio-list-label {
  display: inline;
  white-space: nowrap;
}

.musica-rt-item:nth-child(even) {
  background: #d6e8f5;
}

/* Primer elemento: texto rojo */
.musica-rt-item--first {
  color: #c0392b;
}

.musica-rt-item:active {
  transform: scale(0.995);
}

.musica-rt-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.musica-rt-item--empty {
  background: rgba(255, 255, 255, 0.55);
  color: #445;
  cursor: default;
  text-align: center;
  font-weight: 600;
  font-style: italic;
}

@media (max-width: 640px) {
  .musica-rt-toolbar {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'title title'
      'volver alph';
  }

  .musica-rt-toolbar__title {
    grid-area: title;
  }

  .musica-rt-btn--volver {
    grid-area: volver;
  }

  .musica-rt-btn--alph {
    grid-area: alph;
  }

  .musica-rt-btn {
    min-height: 48px;
    width: 100%;
  }
}

/* =========================================================================
   BÚSQUEDA MUSIC (TEXT: + botón MUSIC — filtrado en memoria)
   ========================================================================= */

.musica-search-view {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem 0.5rem;
}

.list-header {
  flex: 1 1 auto;
  margin: 0;
  padding: 0.65rem 0.85rem;
  text-align: center;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  color: #123a52;
  line-height: 1.3;
  letter-spacing: 0.02em;
  background: #9ec9e8;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  min-width: 0;
}

.musica-search-toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

.musica-search-btn {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.musica-search-btn:active {
  transform: scale(0.97);
}

.musica-search-btn--alph {
  background: #e89ab8;
  color: #4a1030;
}

.musica-search-btn--alph.is-active {
  background: #d4588a;
  color: #fff;
  box-shadow: 0 0 0 2px #8b1e4a, 0 2px 6px rgba(0, 0, 0, 0.15);
}

@media (max-width: 640px) {
  .musica-search-toolbar {
    grid-template-columns: 1fr;
  }

  .musica-search-btn--alph {
    width: 100%;
    min-height: 48px;
  }
}

.musica-search-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0.25rem 0.15rem 0.5rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  box-sizing: border-box;
}

.musica-search-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  margin: 0;
  padding: 0.65rem 1.1rem;
  background: #e8f2fa;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #111;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.musica-search-item--locked {
  opacity: 0.72;
  background: #edf0f3;
  cursor: not-allowed;
}

.musica-search-item__ord {
  flex: 0 0 auto;
  min-width: 2.4em;
  font-weight: 800;
  color: #1a4a6e;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.musica-search-item__label {
  min-width: 0;
  line-height: 1.3;
  display: block;
  padding-bottom: 0.1em;
}

.musica-search-item:nth-child(even) {
  background: #d6e8f5;
}

.musica-search-item:active {
  transform: scale(0.995);
}

.musica-search-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.musica-search-item--empty {
  background: rgba(255, 255, 255, 0.55);
  color: #445;
  cursor: default;
  text-align: center;
  font-weight: 600;
  font-style: italic;
}

/* =========================================================================
   BÚSQUEDA EJER/EXER (verde suave, en línea con listas de clases)
   ========================================================================= */

.ejercicio-search-view {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem 0.5rem;
}

.ejercicio-search-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0.25rem 0.15rem 0.5rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  box-sizing: border-box;
}

.ejercicio-search-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  margin: 0;
  padding: 0.85rem 1.1rem;
  background: #dceee8;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #12352f;
  text-align: left;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ejercicio-search-item__ord {
  flex: 0 0 auto;
  min-width: 2.4em;
  font-weight: 800;
  color: #1e6b58;
  font-variant-numeric: tabular-nums;
}

.ejercicio-search-item__label {
  flex: 1 1 auto;
  min-width: 0;
}

.ejercicios-cell__marquee.ejercicio-list-label {
  display: inline-block;
  white-space: nowrap;
}

.ejercicio-search-item:nth-child(even) {
  background: #cce5dd;
}

.ejercicio-search-item:active {
  transform: scale(0.995);
}

.ejercicio-search-item:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.ejercicio-search-item--empty {
  background: rgba(255, 255, 255, 0.55);
  color: #445;
  cursor: default;
  text-align: center;
  font-weight: 600;
  font-style: italic;
}

/* =========================================================================
   PANTALLA DE MÚSICA (metadatos + acciones)
   ========================================================================= */

.musica-detalle-view {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  /* Scroll interno: cabecera TOP y reproductor BOTTOM quedan fijos en el shell */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
  gap: 0.75rem;
  /* padding-bottom: espacio de seguridad por encima del player-bar fijo */
  padding: 0.4rem 0.35rem 120px;
}

.musica-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.musica-meta__row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: filter 0.12s ease, box-shadow 0.12s ease;
}

.musica-meta__row.is-editable {
  cursor: pointer;
}

.musica-meta__row.is-editable:hover {
  filter: brightness(0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.musica-meta__row.is-editable:active {
  filter: brightness(0.93);
}

.musica-meta__row.is-readonly {
  cursor: default;
}

.musica-meta__row--tags {
  grid-template-columns: 150px 1fr;
  align-items: center;
}

.musica-meta__tags-text {
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #111;
  line-height: 1.35;
  word-break: break-word;
  min-width: 0;
}

.musica-meta__label {
  font-weight: 800;
  font-size: clamp(0.72rem, 1.5vw, 0.85rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #1a2e28;
}

.musica-meta__value {
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #111;
  line-height: 1.35;
  word-break: break-word;
  min-width: 0;
}

.musica-meta__tags-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  flex: 1;
  min-width: 0;
}

.musica-meta__tag-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 5.5rem;
  min-width: 4.5rem;
}

.musica-meta__tag-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.musica-meta__input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}

/* EFECTO EMOC (catálogo readonly): misma tipografía que TITULO/ALBUM/GENERO */
.musica-meta__row--tags .musica-meta__input[readonly],
.musica-meta__input.musica-meta__value--readonly {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: default;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  color: #111;
  line-height: 1.35;
  word-break: break-word;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.musica-meta__value--readonly {
  word-break: break-all;
}

.musica-meta__value--title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.musica-meta__duration {
  font-size: 0.85rem;
  opacity: 0.85;
  white-space: nowrap;
}

.musica-meta__file-btn {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: #457b9d;
  color: #fff;
}

.musica-meta__file-name {
  font-size: 0.85rem;
  margin-left: 0.5rem;
  word-break: break-all;
}

.musica-act-btn--save-meta {
  background: #2a9d8f;
  color: #fff;
}

.musica-meta__row--title { background: #b8ecec; } /* cian claro */
.musica-meta__row--album { background: #9fd6d2; } /* turquesa claro */
.musica-meta__row--genr { background: #d6ebf7; } /* azul muy claro */
.musica-meta__row--tags { background: #efe4c8; } /* beige */
.musica-meta__row--file { background: #c8e6c0; } /* verde claro */

.musica-meta__change {
  min-height: 42px;
  padding: 0.4rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: #7a4fcf;
  color: #fff;
  font-family: inherit;
  font-size: clamp(0.65rem, 1.3vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.musica-meta__change:active {
  transform: scale(0.97);
}

.musica-acciones {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  /* Extra aire al final de la botonera al hacer scroll */
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}

.musica-acciones__saves {
  display: flex;
  flex: 1 1 auto;
  gap: 10px;
  min-width: 0;
}

.musica-acciones__saves .musica-act-btn {
  flex: 1 1 0;
  min-width: 0;
}

.musica-act-btn {
  flex: 1 1 auto;
  min-height: 48px;
  min-width: 7.5rem;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
}

.musica-act-btn:hover {
  filter: brightness(0.9);
}

.musica-act-btn:active {
  transform: scale(0.97);
}

.musica-act-btn--borrar {
  background: #e07a3a;
  color: #fff;
}

.musica-act-btn--save1,
.musica-act-btn--save2,
.musica-act-btn--save3 {
  background: #d5d9dc;
  color: #222;
}

.musica-act-btn--preplay {
  background: #1e6fdb;
  color: #fff;
  flex: 1 1 100%;
}

/* Consulta sin ELIMINAR MÚSICA: PRE-PLAY a ancho completo */
.musica-acciones--solo-preplay .musica-act-btn--preplay {
  flex: 1 1 100%;
  width: 100%;
  min-width: 100%;
}

/* PRE-PLAY NO cambia de color al pulsarse (mantiene azul estándar) */
.musica-act-btn--preplay.btn-active-red {
  background: #1e6fdb !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

@media (max-width: 768px) {
  .musica-detalle-view {
    /* Más margen inferior: player-bar más alto (título + tiempos grandes) */
    padding-bottom: max(140px, calc(120px + env(safe-area-inset-bottom)));
  }

  /* Dentro del <dialog> de detalles: scroll en el panel, no amputar PRE-PLAY */
  .overlay-dialog--musica .musica-detalle-view {
    padding: 0.85rem 1rem 20px;
    padding-bottom: 20px;
    max-height: none;
    overflow: visible;
  }

  .musica-meta__row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.65rem 0.85rem;
  }

  .musica-meta__row--tags {
    grid-template-columns: 1fr;
  }

  .musica-meta__change {
    width: 100%;
    min-height: 48px;
  }

  /* Botonera apilada a ancho completo (evita desbordes con flex-wrap) */
  .musica-acciones {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .musica-acciones__saves {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .musica-act-btn,
  .musica-act-btn--borrar,
  .musica-act-btn--save1,
  .musica-act-btn--save2,
  .musica-act-btn--save3,
  .musica-act-btn--preplay {
    flex: none;
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }
}

/* =========================================================================
   MODALES NATIVOS <dialog> (grupos / clases / secundarios)
   Top-layer vía showModal(); backdrop nativo + clic en .bpw-modal__backdrop
   ========================================================================= */

dialog.bpw-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0;
  border: none;
  padding: 1rem;
  background: transparent;
  color: inherit;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: center;
}

dialog.bpw-modal[open] {
  display: flex;
}

dialog.bpw-modal::backdrop {
  background: rgba(15, 25, 30, 0.55);
  backdrop-filter: blur(2px);
}

/* Compat: nodos legacy aún no migrados */
.bpw-modal:not(dialog) {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.bpw-modal[hidden],
.bpw-modal.is-hidden {
  display: none !important;
}

.bpw-modal__backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.bpw-modal__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 94vw);
  background: #fff;
  border-radius: 16px;
  padding: 1.35rem 1.25rem 1.15rem;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: min(92vh, 92dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bpw-modal__close--form {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
}

@media (max-width: 700px) {
  dialog.bpw-modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  dialog.bpw-modal .bpw-modal__panel {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-sizing: border-box;
  }
}

.bpw-modal__title {
  margin: 0 0 0.25rem;
  padding-right: 2.75rem;
  font-size: 1.15rem;
  color: #1f4d44;
  font-weight: 800;
}

.bpw-modal__label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #345;
}

.bpw-modal__input,
.bpw-modal__select {
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.75rem;
  border: 2px solid #45b1a2;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
}

.bpw-modal__input:focus,
.bpw-modal__select:focus {
  outline: none;
  border-color: #d11f7e;
  box-shadow: 0 0 0 3px rgba(209, 31, 126, 0.18);
}

.bpw-modal__warn {
  margin: 0;
  font-size: 0.9rem;
  color: #6a3030;
  background: #fdecea;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  line-height: 1.4;
}

.bpw-modal__warn--confirm {
  margin-top: 0.25rem;
}

.bpw-modal__hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.3;
}

.bpw-modal__error {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #b71c1c;
}

.bpw-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.bpw-modal__actions--stack {
  grid-template-columns: 1fr;
}

#elim-nuevo-ejer-nombre {
  display: block;
  margin-top: 0.4rem;
  color: #1f4d44;
}

.bpw-modal__btn {
  min-height: 46px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.bpw-modal__btn--cancel {
  background: #e8ecee;
  color: #334;
}

.bpw-modal__btn--ok {
  background: #2a9d8f;
  color: #fff;
}

.bpw-modal__btn--secondary {
  background: #457b9d;
  color: #fff;
}

.bpw-modal__btn--danger {
  background: #d81b60;
  color: #fff;
}

.bpw-modal__btn:active {
  transform: scale(0.97);
}

.bpw-modal__btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.bpw-modal__check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0.15rem 0 0.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: #345;
  line-height: 1.35;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.bpw-modal__check input[type='checkbox'] {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.1rem;
  accent-color: #2a9d8f;
  cursor: pointer;
}

.bpw-modal__info {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f4d44;
  line-height: 1.4;
}

.bpw-file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Modal descripción de ejercicio (scroll obligatorio) --- */
.bpw-modal--descripcion {
  z-index: 320;
  padding: 0.75rem;
  align-items: center;
}

.bpw-modal__panel--descripcion {
  width: min(640px, 96vw);
  max-height: min(85vh, 720px);
  padding: 1rem 1rem 1.1rem;
  gap: 0.75rem;
  overflow: hidden;
}

.bpw-modal__header-desc {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.bpw-modal__header-desc .bpw-modal__title {
  margin: 0;
  flex: 1 1 auto;
  padding-top: 0.35rem;
  line-height: 1.3;
}

.bpw-modal__close {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  background: #e8eef2;
  color: #222;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.bpw-modal__close:active {
  transform: scale(0.95);
  background: #d5dee4;
}

.bpw-modal__close:focus-visible {
  outline: 3px solid #2c6e63;
  outline-offset: 2px;
}

.bpw-modal__desc-body {
  flex: 1 1 auto;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.85rem 1rem;
  background: #f4f7f5;
  border-radius: 10px;
  border: 1px solid #d5e0da;
  color: #1a2e28;
  font-size: clamp(0.95rem, 2.4vw, 1.05rem);
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
}

.bpw-modal__desc-body--empty {
  font-style: italic;
  color: #667;
  text-align: center;
}

@media (max-width: 768px) {
  .bpw-modal__panel--descripcion {
    width: 100%;
    max-height: 90vh;
    border-radius: 14px;
  }

  .bpw-modal__desc-body {
    max-height: 60vh;
    padding: 0.9rem;
    font-size: 1rem;
  }

  .bpw-modal__close {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    font-size: 2rem;
  }
}

/* --- Modal vídeo del ejercicio --- */
.bpw-modal--video {
  z-index: 330;
  padding: 0.75rem;
}

.bpw-modal__panel--video {
  width: min(920px, 96vw);
  max-height: min(92vh, 860px);
  padding: 1rem;
  gap: 0.75rem;
  overflow: hidden;
  background: #111;
}

.bpw-modal__panel--video .bpw-modal__title {
  color: #f2f2f2;
}

.bpw-modal__panel--video .bpw-modal__close {
  background: #2a2a2a;
  color: #fff;
}

.bpw-modal__panel--video .bpw-modal__close:active {
  background: #444;
}

.bpw-modal__video-wrap {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.bpw-modal__video-wrap video {
  width: 100%;
  max-height: 80vh;
  display: block;
  background: #000;
}

@media (max-width: 768px) {
  .bpw-modal__panel--video {
    width: 100%;
    max-height: 94vh;
    border-radius: 12px;
    padding: 0.75rem;
  }

  .bpw-modal__video-wrap video {
    max-height: 70vh;
  }
}

/* --- Modal curva emocional --- */
.bpw-modal--curva {
  z-index: 330;
}

.bpw-modal__panel--curva {
  width: min(920px, 96vw);
  max-height: min(92vh, 820px);
  padding: 1.15rem 1.25rem 1rem;
  gap: 0.75rem;
}

.bpw-modal__title--curva {
  text-align: center;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  margin: 0.15rem 0 0.35rem;
  color: #1f4d44;
}

.bpw-modal__curva-wrap {
  position: relative;
  width: 100%;
  height: min(58vh, 480px);
  min-height: 280px;
  background: linear-gradient(180deg, #f7fbfa 0%, #eef6f4 100%);
  border: 2px solid #45b1a2;
  border-radius: 14px;
  padding: 0.65rem 0.75rem 0.5rem;
}

.bpw-modal__curva-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.bpw-modal__actions--curva {
  grid-template-columns: 1fr;
  max-width: 220px;
  margin: 0.15rem auto 0;
}

.bpw-modal__btn--curva-cerrar {
  background-color: #ef4444;
  color: #fff;
  border: none;
}

.bpw-modal__btn--curva-cerrar:hover,
.bpw-modal__btn--curva-cerrar:focus-visible {
  background-color: #dc2626;
}

.bpw-modal__btn--curva-cerrar:active {
  background-color: #b91c1c;
}

@media (max-width: 640px) {
  .bpw-modal__panel--curva {
    width: 98vw;
    padding: 0.9rem 0.75rem 0.85rem;
  }

  .bpw-modal__curva-wrap {
    height: min(52vh, 360px);
    min-height: 240px;
    padding: 0.4rem;
  }
}

/* --- Modal notas de clase --- */
.bpw-modal--nota {
  z-index: 330;
}

.bpw-modal__panel--nota {
  width: min(560px, 94vw);
  max-height: min(90vh, 720px);
}

.bpw-modal__title--nota {
  text-align: center;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  margin: 0 0 0.35rem;
}

.bpw-modal__textarea {
  width: 100%;
  min-height: 12rem;
  padding: 0.75rem 0.85rem;
  border: 2px solid #45b1a2;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: #234;
  resize: vertical;
  background: #fafefe;
}

.bpw-modal__textarea:focus {
  outline: none;
  border-color: #d11f7e;
  box-shadow: 0 0 0 3px rgba(209, 31, 126, 0.18);
}

@media (max-width: 640px) {
  .bpw-modal__panel--nota {
    width: 96vw;
  }

  .bpw-modal__textarea {
    min-height: 10rem;
  }
}

/* --- Modal: exportar guion de clase --- */
.bpw-modal--exportar {
  z-index: 340;
}

.bpw-modal__panel--exportar {
  width: min(720px, 94vw);
  max-height: min(92vh, 860px);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bpw-modal__label--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bpw-modal__textarea--exportar {
  flex: 1 1 auto;
  min-height: min(58vh, 520px);
  max-height: min(68vh, 620px);
  font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', Menlo, Consolas, monospace;
  font-size: clamp(0.85rem, 2.2vw, 0.98rem);
  line-height: 1.5;
  white-space: pre-wrap;
  resize: vertical;
}

.bpw-modal__actions--exportar {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.55rem;
  margin-top: 0.15rem;
}

@media (max-width: 520px) {
  .bpw-modal__panel--exportar {
    width: 96vw;
    max-height: 94vh;
  }

  .bpw-modal__textarea--exportar {
    min-height: 48vh;
  }

  .bpw-modal__actions--exportar {
    grid-template-columns: 1fr;
  }
}

/* --- Modal matices de ejercicio --- */
.bpw-modal--matices {
  z-index: 335;
}

.bpw-modal__panel--matices {
  width: min(480px, 94vw);
}

.bpw-modal__title--matices {
  text-align: center;
  font-size: clamp(1.02rem, 2.3vw, 1.2rem);
  margin: 0 0 0.25rem;
}

.bpw-modal__textarea--matices {
  min-height: 6.5rem;
  resize: vertical;
}

/* --- Modal: añadir nuevo ejercicio --- */
.bpw-modal--nuevo-ejer {
  z-index: 345;
}

.bpw-modal__panel--nuevo-ejer {
  width: min(560px, 94vw);
  max-height: min(92vh, 820px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0.45rem;
}

.bpw-modal__fieldset {
  margin: 0.15rem 0 0.25rem;
  padding: 0.55rem 0.65rem 0.35rem;
  border: 1px solid rgba(69, 177, 162, 0.35);
  border-radius: 10px;
  min-width: 0;
}

.bpw-modal__fieldset .bpw-modal__label,
.bpw-modal__fieldset legend.bpw-modal__label {
  float: none;
  width: auto;
  padding: 0 0.25rem;
  margin-bottom: 0.35rem;
}

.bpw-modal__section-label {
  margin: 0.55rem 0 0.1rem;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #2a6f66;
  text-transform: uppercase;
}

.bpw-modal__textarea--compact {
  min-height: 3.2rem;
  resize: vertical;
}

@media (max-width: 520px) {
  .bpw-modal__panel--nuevo-ejer {
    width: 96vw;
    max-height: 94vh;
    padding: 0.85rem 0.75rem 1rem;
  }
}

/* --- Toast flotante (viewport; visible también en top-layer / Popover) --- */
/*
 * El UA de [popover] fuerza inset:0 + margin:auto. Si solo se hace inset:unset,
 * el toast queda pegado arriba-izquierda. Hay que anular inset/margin/width
 * de forma explícita y centrar con left + translateX (sin pelear con scale).
 */
.bpw-toast,
.bpw-toast[popover],
.bpw-toast:popover-open {
  box-sizing: border-box;
  position: fixed !important;
  inset: auto !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%);
  z-index: 999999;
  width: max-content !important;
  max-width: min(92vw, 420px) !important;
  height: auto !important;
  margin: 0 !important;
  padding: 12px 24px;
  border: none !important;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.85) !important;
  color: #fff !important;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
  overflow: visible !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.bpw-toast.is-hidden {
  display: none !important;
}

.bpw-toast.is-visible,
.bpw-toast:popover-open.is-visible {
  display: block !important;
  opacity: 1;
  transform: translate(-50%, -50%);
}

/* Toast dentro de dialog (fallback): mismo anclaje al viewport del top-layer */
dialog[open] > .bpw-toast,
.bpw-toast-dialog > .bpw-toast {
  z-index: 999999;
}

/* Shell top-layer (fallback sin Popover): transparente, sin atrapar clics */
.bpw-toast-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
  pointer-events: none;
}

.bpw-toast-dialog::backdrop {
  background: transparent;
  pointer-events: none;
}

/* --- Modal: NUEVAS MÚSICAS (mismo patrón que NUEVOS EJERCICIOS) --- */
.bpw-modal--nuevas-musicas {
  z-index: 345;
}

.bpw-modal--nuevos-videos {
  z-index: 345;
}

.bpw-modal__panel--nuevas-musicas-form,
.bpw-modal__panel--nuevos-videos-form {
  width: min(560px, 94vw);
  max-height: min(92vh, 820px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.add-music-form--modal {
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 0.85rem;
}

.add-music-form--modal .add-music-form__summary,
.add-music-form--modal .add-music-form__result {
  margin: 0;
}

.add-music-form--modal .add-music-form__actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.65rem;
}

@media (max-width: 520px) {
  .bpw-modal__panel--nuevas-musicas-form {
    width: 96vw;
    max-height: 94vh;
  }
}

/* Listado multi-select para eliminar NEWMUSIC */
.new-music-delete-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(48vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.35rem 0 0.75rem;
  padding: 0.15rem;
}

.new-music-delete-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(110, 198, 232, 0.35);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.new-music-delete-item:hover,
.new-music-delete-item.is-selected {
  background: #eef8fb;
  border-color: rgba(47, 158, 143, 0.45);
}

.new-music-delete-item input[type='checkbox'] {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  accent-color: #c0392b;
}

.new-music-delete-item__label {
  flex: 1 1 auto;
  font-size: clamp(0.88rem, 2.2vw, 0.98rem);
  line-height: 1.35;
  color: #1a3a2f;
  word-break: break-word;
}

/* --- Formularios de importación / paneles (dentro del modal) --- */
.add-music-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 0.75rem clamp(0.85rem, 3vw, 1.35rem) 0.5rem;
}

.add-music-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.2rem 1.25rem;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(110, 198, 232, 0.35);
}

.add-music-card--summary {
  gap: 1rem;
  padding: 1.35rem 1.25rem 1.4rem;
  background: linear-gradient(180deg, #ffffff 0%, #f0fafd 100%);
  border-color: rgba(47, 158, 143, 0.28);
}

.add-music-card__title {
  margin: 0;
  font-size: clamp(0.82rem, 2vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1f6b4a;
}

.add-music-card__label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e3a36;
}

.add-music-submenu {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 0.75rem clamp(0.85rem, 3vw, 1.35rem) 1rem;
}

.add-music-submenu.is-hidden,
.add-music-panel.is-hidden,
.add-music-panel[hidden] {
  display: none !important;
}

.add-music-submenu__btn {
  appearance: none;
  width: 100%;
  min-height: 3.4rem;
  padding: 0.95rem 1.2rem;
  border: none;
  border-radius: 14px;
  border-bottom: 4px solid transparent;
  font: inherit;
  font-size: clamp(0.92rem, 2.3vw, 1.08rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.add-music-submenu__btn:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.add-music-submenu__btn:active {
  transform: translateY(0) scale(0.985);
}

.add-music-submenu__btn--add {
  background: var(--menu-exercise);
  color: #fff;
  border-bottom-color: #217a6e;
}

.add-music-submenu__btn--modify {
  background: var(--menu-music);
  color: #0a2f3d;
  border-bottom-color: #3a9fc4;
}

.add-music-submenu__btn--delete {
  background: var(--menu-export);
  color: #fff;
  border-bottom-color: #b01f72;
}

.add-music-select {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid rgba(62, 152, 184, 0.55);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  color: #0a2f3d;
  background: #fff;
}

.add-music-select:focus {
  outline: none;
  border-color: var(--menu-music);
  box-shadow: 0 0 0 3px rgba(110, 198, 232, 0.35);
}

.add-music-form__empty {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #6a3030;
  background: #fdecea;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  line-height: 1.4;
}

.add-music-form__empty.is-hidden,
.add-music-form__empty[hidden] {
  display: none !important;
}

/* Contenedor del input file */
.add-music-dropzone {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.add-music-dropzone__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.add-music-dropzone__input:disabled {
  cursor: not-allowed;
}

.add-music-dropzone.is-disabled .add-music-dropzone__label {
  opacity: 0.55;
  pointer-events: none;
}

.add-music-dropzone__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 7.5rem;
  padding: 1.35rem 1.1rem;
  text-align: center;
  background: linear-gradient(145deg, #eaf7fc 0%, #f7fcfe 55%, #eef8f5 100%);
  border: 2px dashed rgba(62, 152, 184, 0.55);
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.add-music-dropzone:hover:not(.is-disabled) .add-music-dropzone__label,
.add-music-dropzone:focus-within .add-music-dropzone__label {
  border-color: var(--menu-music);
  background: #e4f5fb;
  box-shadow: 0 4px 14px rgba(110, 198, 232, 0.28);
}

.add-music-dropzone__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.55rem 1.35rem;
  border-radius: 999px;
  background: var(--menu-import);
  color: #fff;
  font-size: clamp(0.82rem, 2vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(59, 111, 217, 0.3);
  pointer-events: none;
}

.add-music-dropzone__hint {
  max-width: 22rem;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: #3a5a66;
  pointer-events: none;
}

.add-music-form__summary,
.add-music-form__result {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.12rem);
  font-weight: 700;
  color: #0a2f3d;
  line-height: 1.4;
}

.add-music-form__summary:not([hidden]) {
  padding: 0.85rem 1rem;
  background: rgba(110, 198, 232, 0.18);
  border-radius: 12px;
  border-left: 4px solid var(--menu-music);
}

.add-music-form__result:not([hidden]) {
  color: #145a32;
  padding: 0.85rem 1rem;
  background: rgba(159, 211, 138, 0.28);
  border-radius: 12px;
  border-left: 4px solid var(--menu-grupos);
}

.add-music-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  margin-top: 0.35rem;
}

.add-music-form__import {
  appearance: none;
  border: none;
  background: var(--menu-exercise);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: clamp(0.95rem, 2.3vw, 1.08rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.9rem 1.75rem;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 3.15rem;
  box-shadow: 0 4px 14px rgba(47, 158, 143, 0.35);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.add-music-form__import:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 6px 18px rgba(47, 158, 143, 0.42);
}

.add-music-form__import:active:not(:disabled) {
  transform: scale(0.985);
}

.add-music-form__import:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

.add-music-form__import:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.add-music-form__import--danger {
  background: var(--menu-export);
  box-shadow: 0 4px 14px rgba(224, 58, 154, 0.35);
}

.add-music-form__import--danger:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(224, 58, 154, 0.42);
}

.add-music-hourglass {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: #1f6b4a;
  font-size: 1rem;
  padding: 0.35rem 0.75rem;
  background: rgba(159, 211, 138, 0.22);
  border-radius: 999px;
}

.add-music-hourglass[hidden] {
  display: none !important;
}

.add-music-hourglass.is-active .add-music-hourglass__icon {
  display: inline-block;
  animation: bpw-hourglass-flip 1.1s ease-in-out infinite;
  transform-origin: 50% 55%;
  font-size: 1.45rem;
  line-height: 1;
}

@keyframes bpw-hourglass-flip {
  0% {
    transform: rotate(0deg);
  }
  40% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(180deg);
  }
}

@media (max-width: 520px) {
  .add-music-submenu {
    padding: 0.6rem 0.7rem 0.85rem;
  }

  .add-music-form {
    gap: 1rem;
    padding: 0.6rem 0.7rem 0.35rem;
  }

  .add-music-card {
    padding: 1rem 0.9rem 1.05rem;
    border-radius: 12px;
  }

  .add-music-form__import {
    width: 100%;
  }

  .add-music-form__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .add-music-hourglass {
    justify-content: center;
  }
}

/* --- Modal: ACERCA DE BIODANZA PLAYER --- */
.bpw-modal--about {
  z-index: 350;
}

.bpw-modal__panel--about {
  width: min(720px, 96vw);
  padding: 0;
  gap: 0;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.about-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.05rem 1rem 0.95rem 1.25rem;
  background: linear-gradient(135deg, #e8f6f4 0%, #f4fbf9 55%, #eef7fc 100%);
  border-bottom: 1px solid rgba(69, 177, 162, 0.28);
}

.about-modal__heading {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.about-modal__product {
  margin: 0;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #1f4d44;
  line-height: 1.25;
}

.about-modal__version {
  margin: 0;
  font-size: clamp(0.82rem, 2vw, 0.95rem);
  font-weight: 700;
  color: #2a6f66;
  letter-spacing: 0.02em;
}

.about-modal__body {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.35rem;
}

.about-modal__section {
  padding: 0.95rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  border-radius: 8px;
}

.about-modal__section--music {
  border-right: none;
  background: #e1f0ff;
}

.about-modal__section--ejercicios {
  background: #d8f3e5;
}

.about-modal__section--videos {
  background: #f3e8dc;
}

.about-modal__section-title {
  margin: 0 0 0.2rem;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1f6b4a;
  line-height: 1.2;
}

.about-modal__section--music .about-modal__section-title {
  color: #0a2f3d;
}

.about-modal__section--videos .about-modal__section-title {
  color: #5a3a1a;
}

.about-modal__stats {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.about-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
}

.about-stat__label {
  flex: 1 1 auto;
  font-size: 0.86rem;
  font-weight: 600;
  color: #345;
  line-height: 1.3;
}

.about-stat__value {
  flex: 0 0 auto;
  font-size: 1.15rem;
  font-weight: 800;
  color: #1a3d12;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 2.5ch;
}

.about-modal__section--music .about-stat__value {
  color: #0a2f3d;
}

.about-modal__section--videos .about-stat__value {
  color: #6a4120;
}

.about-stat:last-child .about-stat__label,
.about-stat:last-child .about-stat__value {
  margin-top: 0.15rem;
  padding-top: 0.4rem;
  border-top: 1px dashed rgba(42, 111, 102, 0.28);
}

.about-stat:last-child .about-stat__value {
  font-size: 1.28rem;
  color: var(--menu-exercise);
}

.about-modal__section--music .about-stat:last-child .about-stat__value {
  color: var(--menu-import);
}

.about-modal__section--videos .about-stat:last-child .about-stat__value {
  color: var(--menu-video);
}

.about-modal__footer {
  display: flex;
  justify-content: center;
  padding: 0.85rem 1.15rem 1.1rem;
  border-top: 1px solid rgba(69, 177, 162, 0.2);
  background: #fafcfc;
}

.about-modal__footer .bpw-modal__btn {
  min-width: min(100%, 200px);
}

@media (max-width: 720px) {
  .about-modal__body {
    grid-template-columns: 1fr;
  }

  .about-modal__section--music {
    border-right: none;
    border-bottom: none;
  }

  .bpw-modal__panel--about {
    width: min(420px, 96vw);
  }
}

/* ==========================================================================
   Panel de administración
   ========================================================================== */

.admin-panel {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.admin-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-panel__title {
  margin: 0;
  font-size: 1.35rem;
  color: #1a5c55;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.admin-tab {
  border: 1px solid #45b1a2;
  background: #fff;
  color: #1a5c55;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.admin-tab.is-active {
  background: #45b1a2;
  color: #fff;
}

.admin-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.admin-search {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.admin-btn {
  border: 1px solid #888;
  background: #f5f5f5;
  color: #222;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.admin-btn--primary {
  background: #45b1a2;
  border-color: #3a9689;
  color: #fff;
}

.admin-btn--danger {
  background: #c0392b;
  border-color: #a93226;
  color: #fff;
}

.admin-btn--logout {
  background: #555;
  border-color: #444;
  color: #fff;
}

.admin-btn--small {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: #eef8f6;
  color: #1a5c55;
  font-weight: 700;
}

.admin-table__actions {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
}

.admin-empty {
  color: #666;
  font-style: italic;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.admin-stat-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.admin-stat-card__label {
  display: block;
  font-size: 0.78rem;
  color: #666;
  margin-bottom: 0.2rem;
}

.admin-stat-card__value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a5c55;
}

.admin-section-title {
  margin: 0.75rem 0 0.5rem;
  color: #1a5c55;
  font-size: 1rem;
}

.admin-online {
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: linear-gradient(165deg, #eef9f6 0%, #dceee8 100%);
  border: 1px solid rgba(69, 177, 162, 0.28);
}

.admin-online-subtitle {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: #2a6a62;
}

.admin-online-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.9rem;
  color: #234;
}

.admin-online-list__meta {
  font-weight: 500;
  color: #556;
  font-size: 0.85rem;
}

.admin-online-empty {
  margin: 0.25rem 0 0;
}

.admin-stat-card--online {
  background: rgba(255, 255, 255, 0.72);
}

.admin-table td.admin-cell--online,
.admin-table .admin-cell--online {
  font-weight: 800;
  color: #1b7a5a;
}

.admin-sys-path {
  font-size: 0.85rem;
  color: #444;
  word-break: break-all;
}

.admin-user-modal__panel {
  width: min(480px, 96vw);
}

.admin-user-form {
  display: grid;
  gap: 0.65rem;
  padding: 0 1rem 1rem;
}

.admin-field {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.admin-field input[type='text'],
.admin-field input[type='number'] {
  padding: 0.4rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.admin-field--checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.admin-user-form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 640px) {
  .admin-panel__header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-table {
    font-size: 0.82rem;
  }
}

.admin-ejercicio-modal__panel {
  width: min(720px, 96vw);
  max-height: 92vh;
  overflow: auto;
}

.admin-ejercicio-form {
  max-height: calc(92vh - 4rem);
  overflow: auto;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.admin-lang-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

.admin-lang-tab {
  border: 1px solid #45b1a2;
  background: #fff;
  color: #1a5c55;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-lang-tab.is-active {
  background: #45b1a2;
  color: #fff;
}

.admin-field textarea {
  padding: 0.4rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
  min-height: 5rem;
}

.admin-readonly-meta {
  font-size: 0.85rem;
  color: #555;
  margin: 0 0 0.5rem;
}

.admin-hint {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 0.65rem;
}

.admin-table--ejercicios td:nth-child(2) {
  max-width: 280px;
}
