/* Colores y letras: los mismos de la propuesta aprobada.
   Las tres primeras fuentes de cada lista todavía no están en la app; mientras
   tanto se usan las del sistema, que vienen después. */
:root {
  --bg: #F1F4F1;
  --surface: #FFFFFF;
  --surface-2: #E6EBE7;
  --ink: #14201E;
  --muted: #53625E;
  --line: #CCD5D0;
  --amber: #9A5E0B;
  --amber-soft: #F4E3C4;
  --teal: #1B6B66;
  --teal-soft: #D2E6E3;
  --on-strong: #FFFFFF;
  --key-w: #FFFFFF;
  --key-b: #1A2422;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1514; --surface: #171F1D; --surface-2: #212B29; --ink: #E8EEEA; --muted: #97A6A1; --line: #2E3A37;
    --amber: #E2A547; --amber-soft: #3D2E12; --teal: #62C2BA; --teal-soft: #173836; --on-strong: #0F1514;
    --key-w: #DDE5E0; --key-b: #070B0A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1514; --surface: #171F1D; --surface-2: #212B29; --ink: #E8EEEA; --muted: #97A6A1; --line: #2E3A37;
  --amber: #E2A547; --amber-soft: #3D2E12; --teal: #62C2BA; --teal-soft: #173836; --on-strong: #0F1514;
  --key-w: #DDE5E0; --key-b: #070B0A;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font: 400 1rem/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* al tacto: dos toques seguidos no agrandan la página, y dejar el dedo no selecciona el texto */
button, summary, input[type="range"] { touch-action: manipulation; }
button, summary { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button:disabled { cursor: default; opacity: 0.4; }
h1, h2, p, dl, dd { margin: 0; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Marco general ---------- */
.marco {
  max-width: 64rem; margin-inline: auto; min-height: 100vh; min-height: 100dvh;
  padding-block: calc(clamp(0.75rem, 3vw, 2.25rem) + env(safe-area-inset-top, 0px)) calc(1.25rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 0.9rem;
}
.app {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
/* Puesta en la pantalla de inicio del iPhone o el iPad, la app llega hasta arriba.
   Esta franja oscura queda bajo la hora y la batería, que ahí salen en blanco. */
body::before {
  content: ""; position: fixed; z-index: 20; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px); background: #0F1514;
}
.app.soltando::after {
  content: "Suelta la canción para abrirla";
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center; padding: 1rem; text-align: center;
  background: var(--surface); border: 2px dashed var(--teal); border-radius: 14px;
  font: 700 1.4rem/1.2 var(--font-display); color: var(--teal);
}
.nota-pie { font: 400 0.72rem/1.4 var(--font-data); color: var(--muted); text-align: center; }
.menor { font-size: 0.86rem; color: var(--muted); }
.rotulo { font: 500 0.72rem/1.2 var(--font-data); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.fila { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

/* ---------- Barra superior ---------- */
.barra { display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); }
.cancion { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; flex: 1; }
.cancion strong { font: 700 1.3rem/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cancion span { font: 500 0.7rem/1 var(--font-data); letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; }

/* Botones comunes */
.ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.4rem; padding: 0.45rem 0.8rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 500 0.9rem/1 var(--font-body); white-space: nowrap; user-select: none; -webkit-user-select: none;
}
.ctl svg { width: 1.1rem; height: 1.1rem; flex: none; }
.ctl.sq { width: 2.4rem; padding: 0; font: 500 1.1rem/1 var(--font-data); }
.ctl.chico { min-height: 1.9rem; padding: 0.3rem 0.6rem; font-size: 0.8rem; border-radius: 7px; }
.ctl.chico.sq { width: 1.9rem; padding: 0; font-size: 1rem; }
@media (hover: hover) { .ctl:not(:disabled):hover { background: var(--surface-2); } }
.ctl:not(:disabled):active { background: var(--line); }
.ctl[aria-pressed="true"], .ctl[aria-pressed="true"]:not(:disabled):hover { background: var(--teal); border-color: var(--teal); color: var(--on-strong); }
.ctl.fuerte, .ctl.fuerte:not(:disabled):hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.principal {
  border: 1px solid var(--ink); border-radius: 10px; background: var(--ink); color: var(--bg);
  padding: 0.85rem 1.4rem; font: 600 1rem/1 var(--font-body);
}
@media (hover: hover) { .principal:hover { opacity: 0.88; } }
.principal:active { opacity: 0.8; }
.enlace {
  border: 0; background: none; padding: 0;
  font: inherit; color: var(--teal); text-decoration: underline; text-underline-offset: 0.15em;
}

.marca { font: 800 1.3rem/1.2 var(--font-display); letter-spacing: -0.01em; }

/* Lista de atajos del teclado */
.ayuda { position: relative; margin-left: auto; }
.ayuda summary { list-style: none; cursor: pointer; }
.ayuda summary::-webkit-details-marker { display: none; }
.ayuda[open] summary { background: var(--surface-2); }
.ayuda-panel {
  position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 6; width: min(24rem, calc(100vw - 2rem));
  padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
}
.ayuda-panel dl { display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.88rem; }
.ayuda-panel dl > div { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 0.6rem; align-items: baseline; }
kbd {
  display: inline-block; min-width: 1.5rem; padding: 0.12rem 0.35rem; text-align: center;
  font: 500 0.74rem/1.3 var(--font-data); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px;
}
@media (pointer: coarse) { .ayuda { display: none; } }

/* ---------- Aviso ---------- */
.aviso {
  position: sticky; top: calc(0.5rem + env(safe-area-inset-top, 0px)); z-index: 7;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin: 0.8rem 1rem 0; padding: 0.7rem 0.9rem;
  border: 1px solid var(--amber); border-radius: 10px; background: var(--amber-soft);
  font-size: 0.94rem;
}
.aviso span { flex: 1; min-width: 12rem; }
.consejo {
  margin: 0.8rem 1rem 0; padding: 0.7rem 0.9rem;
  border: 1px solid var(--teal); border-radius: 10px; background: var(--teal-soft);
  font-size: 0.92rem;
}

/* ---------- Portada: sin canción, o mientras se abre ---------- */
.portada {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: clamp(2.5rem, 9vw, 5.5rem) 1.25rem; text-align: center;
}
.portada h1 { font: 800 clamp(1.6rem, 4.5vw, 2.4rem)/1.1 var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.portada p { max-width: 30rem; color: var(--muted); }
.adorno { position: relative; width: min(20rem, 82%); height: 4.5rem; display: flex; align-items: center; gap: 3px; margin-bottom: 0.4rem; }
.adorno i { flex: 1; min-width: 2px; border-radius: 1px; background: var(--muted); opacity: 0.45; }
.adorno i.en { background: var(--teal); opacity: 1; }
.adorno b { position: absolute; top: 0; bottom: 0; left: 44%; width: 2px; background: var(--amber); }
.barra-espera { position: relative; width: min(18rem, 70%); height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.barra-espera::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%;
  border-radius: 2px; background: var(--teal);
  animation: vaiven 1.1s ease-in-out infinite alternate;
}
@keyframes vaiven { to { left: 65%; } }
@media (prefers-reduced-motion: reduce) {
  .barra-espera::after { animation: none; width: 100%; opacity: 0.5; }
}

/* ---------- Biblioteca: la lista de canciones ---------- */
.biblio { padding: clamp(1.2rem, 4vw, 2.2rem) clamp(1rem, 4vw, 2rem) 1.6rem; display: flex; flex-direction: column; gap: 1rem; }
.biblio-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; }
.biblio-cabeza h1 { font: 800 clamp(1.6rem, 4vw, 2.2rem)/1.1 var(--font-display); letter-spacing: -0.02em; }
input[type="search"] {
  width: min(100%, 24rem); min-height: 2.4rem; padding: 0.4rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 400 0.95rem/1.2 var(--font-body);
}
.canciones { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.cancion-fila { display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--line); }
.cancion-abrir {
  flex: 1; min-width: 0; border: 0; background: none; text-align: left;
  padding: 0.8rem 0.4rem 0.8rem 0; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 0.15rem 0.7rem; align-items: baseline;
}
.cancion-abrir strong { font: 700 1.15rem/1.25 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .cancion-abrir:hover strong { text-decoration: underline; text-underline-offset: 0.15em; } }
.cancion-artista { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cancion-abrir small { grid-column: 1 / -1; font: 400 0.74rem/1.4 var(--font-data); color: var(--muted); }
.cancion-acciones { display: flex; gap: 0.15rem; flex: none; }
.cancion-acciones .icono { width: 2.2rem; height: 2.2rem; }
.cancion-acciones .icono svg { width: 1.15rem; height: 1.15rem; }
.fila-edicion { flex: 1; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.75rem; padding: 0.7rem 0; }
.fila-edicion label { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 12rem; min-width: 0; font: 500 0.72rem/1.2 var(--font-data); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.fila-edicion input[type="text"] { width: 100%; min-height: 2.2rem; }

/* ---------- Mapa de la canción ---------- */
.mapa { padding: 0.8rem 1rem 0.1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.mapa-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; flex-wrap: wrap; }
.tramos-caja { position: relative; padding-bottom: 6px; }
.tramos { display: flex; gap: 3px; }
.tramo {
  min-width: 0; overflow: hidden; border: 0; border-radius: 6px; padding: 0.42rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.15rem; text-align: left;
  background: var(--surface-2); color: var(--ink);
}
.tramo b { font: 600 0.82rem/1.2 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tramo i { font: 400 0.68rem/1.1 var(--font-data); font-style: normal; color: var(--muted); white-space: nowrap; overflow: hidden; }
.tramo.verso { background: var(--teal-soft); }
.tramo.coro { background: var(--amber-soft); }
.tramo.sin-nombre b { font-weight: 400; color: var(--muted); }
.tramo.sin-nombre:only-child i { white-space: normal; }  /* la pista de cómo empezar puede ocupar dos renglones */
.tramo.ahora { outline: 2px solid var(--amber); outline-offset: -2px; }
.tramo.sin-nombre.ahora:only-child { outline: none; }  /* sin secciones no hay nada que resaltar */
@media (hover: hover) { .tramo:hover { filter: brightness(0.96); } }
.tramo:active { filter: brightness(0.92); }
.ventana { position: absolute; bottom: 0; height: 3px; border-radius: 2px; background: var(--ink); opacity: 0.5; pointer-events: none; }
.editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font-size: 0.86rem;
}
.editor label { color: var(--muted); }
input[type="text"] {
  min-height: 1.9rem; padding: 0.25rem 0.5rem; min-width: 0;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink);
  font: 500 0.9rem/1.2 var(--font-body);
}
.editor input[type="text"] { flex: 1 1 9rem; max-width: 16rem; }
.compases { display: flex; gap: 0.6rem; align-items: baseline; font: 400 0.74rem/1.3 var(--font-data); }

/* ---------- Onda ---------- */
.zona-onda { padding: 0.6rem 1rem 0.8rem; display: flex; flex-direction: column; gap: 0.3rem; }
.regla { position: relative; height: 1.05rem; overflow: hidden; }
.regla span {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--line); padding-left: 0.3rem;
  font: 400 0.7rem/1.5 var(--font-data); color: var(--muted); white-space: nowrap;
}
.onda {
  position: relative; height: clamp(6.5rem, 22vh, 10rem);
  border-radius: 8px; background: var(--surface-2); overflow: hidden;
  cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.onda canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.onda .bucle { position: absolute; top: 0; bottom: 0; left: 0; background: var(--teal-soft); pointer-events: none; }
.onda .bucle.apagado { background: none; border-block: 1px dashed var(--muted); opacity: 0.7; }
.marcas span {
  position: absolute; bottom: 5px; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 500 0.66rem/1 var(--font-data); background: var(--surface); color: var(--ink);
  padding: 0.2rem 0.32rem; border-radius: 3px; pointer-events: none;
}
.borde { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--teal); cursor: ew-resize; touch-action: none; }
.borde::before { content: ""; position: absolute; top: 0; bottom: 0; left: -10px; right: -10px; }  /* zona fácil de agarrar */
.borde em {
  position: absolute; top: 0; font: 500 0.68rem/1 var(--font-data); font-style: normal;
  background: var(--teal); color: var(--on-strong); padding: 0.22rem 0.34rem;
}
.borde.a em { left: 2px; border-bottom-right-radius: 4px; }
.borde.b em { right: 2px; border-bottom-left-radius: 4px; }
.borde.a.afuera em { left: auto; right: 2px; border-radius: 0 0 0 4px; }
.borde.b.afuera em { right: auto; left: 2px; border-radius: 0 0 4px 0; }
.borde.apagado, .borde.apagado em { background: var(--muted); }
.cabezal { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--amber); pointer-events: none; will-change: transform; }
.guia { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--ink); opacity: 0.35; pointer-events: none; }
.guia-hora {
  position: absolute; top: 1.7rem; left: 0; pointer-events: none; white-space: nowrap;
  font: 500 0.7rem/1 var(--font-data); background: var(--ink); color: var(--bg);
  padding: 0.24rem 0.38rem; border-radius: 4px;
}
.onda-pie { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; font: 400 0.72rem/1.4 var(--font-data); color: var(--muted); }
.onda-pie .zoom { margin-left: auto; }
.con-tacto { display: none; }
@media (pointer: coarse) {
  .con-raton { display: none; }
  .con-tacto { display: inline; }
}

/* ---------- Controles ---------- */
.cuerpo { border-top: 1px solid var(--line); }
.transporte { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 1rem 1rem 0.1rem; }
.t-mover, .t-bucle { display: flex; align-items: center; gap: 0.5rem; }
.separador { width: 1px; align-self: stretch; margin: 0.4rem 0.3rem; background: var(--line); }
.tocar {
  flex: none; width: 3.5rem; height: 3.5rem; border: 0; border-radius: 50%;
  background: var(--amber); color: var(--on-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.tocar svg { width: 1.7rem; height: 1.7rem; }
@media (hover: hover) { .tocar:hover { filter: brightness(1.08); } }
.tocar:active { transform: scale(0.96); }
.tiempo { margin-left: auto; font: 500 1.3rem/1 var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tiempo small { font-size: 0.85rem; font-weight: 400; color: var(--muted); }

.rejilla { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.col-principal { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.col-lateral { margin-top: 1rem; border-left: 1px solid var(--line); border-top: 1px solid var(--line); border-top-left-radius: 10px; display: flex; flex-direction: column; min-width: 0; }

.diales { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dial { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.dial-fila { display: flex; align-items: center; gap: 0.5rem; }
.grande {
  flex: 1; min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 0.45rem;
  font: 700 2.5rem/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.grande small { font: 500 0.88rem/1.3 var(--font-body); color: var(--muted); }
.fichas { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ficha {
  min-width: 2.6rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted);
  font: 500 0.8rem/1 var(--font-data); user-select: none; -webkit-user-select: none;
}
@media (hover: hover) { .ficha:hover { background: var(--surface-2); } }
.ficha:active { background: var(--surface-2); }
.ficha[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.fina { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.15rem 0.5rem; font: 400 0.76rem/1.3 var(--font-data); color: var(--muted); }
.fina output { margin-left: auto; white-space: nowrap; }
.fina .enlace { flex-basis: 100%; text-align: right; }  /* en su propia línea, a la derecha */

/* Notas: una barra por nota sobre un teclado */
.notas { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.notas-cabeza { display: flex; align-items: center; gap: 0.5rem 0.75rem; flex-wrap: wrap; }
.notas-cabeza .al-final { margin-left: auto; }
.sugeridas { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; min-height: 1.5rem; }
.sugeridas strong { font: 700 1.05rem/1.3 var(--font-display); color: var(--teal); }
.teclado-caja { overflow-x: auto; overflow-y: hidden; padding-bottom: 0.2rem; overscroll-behavior-x: contain; }
/* el aire a los lados es para que quepan los nombres de la primera y la última tecla */
.teclado { display: grid; grid-template-columns: repeat(48, minmax(0, 1fr)); gap: 2px; min-width: 26rem; padding-inline: 0.55rem; }
/* align-items: los botones no estiran su contenido por defecto, y las barras quedarían sin ancho */
.nota { min-width: 0; border: 0; padding: 0; background: none; display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.nota .fuerza { height: 4.6rem; display: flex; align-items: flex-end; }
.nota .fuerza b { display: block; width: 100%; min-height: 1px; border-radius: 2px 2px 0 0; background: var(--muted); opacity: 0.45; }
.nota .tecla { height: 1.7rem; border: 1px solid var(--line); border-radius: 0 0 3px 3px; background: var(--key-w); }
.nota.negra .tecla { background: var(--key-b); }
.nota .nombre { position: relative; height: 0.95rem; }
.nota .nombre:not(:empty) {
  left: 50%; width: max-content; transform: translateX(-50%);
  font: 400 0.62rem/1.5 var(--font-data); color: var(--muted); white-space: nowrap;
}
@media (hover: hover) { .nota:hover .tecla { border-color: var(--ink); } }
.nota:focus-visible .tecla { border-color: var(--ink); }
.nota:active .tecla { filter: brightness(0.82); }
.nota:focus-visible { outline-offset: 1px; border-radius: 3px; }
.nota.sugerida .fuerza b { background: var(--teal); opacity: 1; }
.nota.sugerida .tecla { box-shadow: inset 0 -7px 0 var(--teal); }
.nota.sugerida .nombre { color: var(--teal); font-weight: 500; }
.nota.sugerida.desafinada .fuerza b { background: var(--amber); }
.nota.sugerida.desafinada .tecla { box-shadow: inset 0 -7px 0 var(--amber); }
.nota.sugerida.desafinada .nombre { color: var(--amber); }

/* Panel de bucles */
.pestana { padding: 0 1rem; border-bottom: 1px solid var(--line); font: 600 0.9rem/1.1 var(--font-body); }
.pestana span { display: inline-block; padding: 0.8rem 0.1rem 0.6rem; border-bottom: 3px solid var(--amber); margin-bottom: -1px; }
.panel { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lista:empty { display: none; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.1rem 0.6rem;
  padding: 0.5rem 0 0.5rem 0.6rem; border-bottom: 1px solid var(--line); border-left: 3px solid transparent;
}
.item.activo { border-left-color: var(--teal); }
.item-tocar {
  min-width: 0; border: 0; background: none; padding: 0.1rem 0; text-align: left;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.item-tocar b { font: 600 0.92rem/1.25 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.activo .item-tocar b { color: var(--teal); }
@media (hover: hover) { .item-tocar:hover b { text-decoration: underline; text-underline-offset: 0.15em; } }
.item-tocar span, .item-ajustes { font: 400 0.72rem/1.3 var(--font-data); color: var(--muted); }
.item-ajustes { text-align: right; white-space: nowrap; }
.item-nombre { grid-column: 1; min-width: 0; }
.item-acciones { display: flex; gap: 0.2rem; }
.icono {
  width: 1.8rem; height: 1.8rem; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: none; color: var(--muted);
}
@media (hover: hover) { .icono:hover { background: var(--surface-2); color: var(--ink); } }
.icono:active { background: var(--surface-2); color: var(--ink); }
.icono svg { width: 0.95rem; height: 0.95rem; }
.item-cambios { grid-column: 1 / -1; font: 400 0.74rem/1.3 var(--font-data); color: var(--muted); }
.pausa { display: flex; flex-direction: column; gap: 0.45rem; }
.panel.con-raya { border-top: 1px solid var(--line); }
textarea {
  display: block; width: 100%; min-height: 5.5rem; resize: vertical; padding: 0.55rem 0.65rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 400 0.95rem/1.45 var(--font-body);
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 0.8; }

/* Deslizadores. --desde y --hasta (de 0 a 1) marcan el tramo relleno; los pone el código. */
input[type="range"] {
  --desde: 0; --hasta: 0; --perilla: 16px;
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 1.5rem; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]:focus-visible { outline-offset: 0; border-radius: 6px; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right,
    var(--surface-2) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--desde)),
    var(--ink) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--desde)),
    var(--ink) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--hasta)),
    var(--surface-2) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--hasta)));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: var(--perilla); height: var(--perilla); margin-top: calc((4px - var(--perilla)) / 2);
  border-radius: 50%; background: var(--surface); border: 2px solid var(--ink);
}
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right,
    var(--surface-2) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--desde)),
    var(--ink) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--desde)),
    var(--ink) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--hasta)),
    var(--surface-2) calc(var(--perilla) / 2 + (100% - var(--perilla)) * var(--hasta)));
}
input[type="range"]::-moz-range-thumb {
  width: calc(var(--perilla) - 4px); height: calc(var(--perilla) - 4px);
  border-radius: 50%; background: var(--surface); border: 2px solid var(--ink);
}
@media (pointer: coarse) {
  input[type="range"] { --perilla: 24px; height: 2.25rem; }
}

/* ---------- Datos técnicos, al pie ---------- */
.datos {
  align-self: center; width: min(100%, 40rem); padding: 0.8rem 0.9rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.datos pre {
  margin: 0; width: 100%; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 400 0.74rem/1.5 var(--font-data); color: var(--ink);
  user-select: text; -webkit-user-select: text;
}

/* ---------- Pantallas medianas y angostas ---------- */
@media (max-width: 56rem) {
  .rejilla { grid-template-columns: minmax(0, 1fr); }
  .col-lateral { margin-top: 0; border-left: 0; border-top-left-radius: 0; }
}
@media (max-width: 36rem) {
  .barra { padding: 0.7rem 0.8rem; gap: 0.6rem; }
  .cancion { flex-direction: column; align-items: flex-start; gap: 0.1rem; }
  .cancion strong { font-size: 1.1rem; max-width: 100%; }
  .aviso, .consejo { margin-inline: 0.8rem; }
  .mapa, .zona-onda { padding-inline: 0.8rem; }
  .transporte { padding: 0.8rem 0.8rem 0.1rem; }
  .separador { display: none; }
  .tiempo { font-size: 1.15rem; }
  .col-principal { padding: 0.8rem; }
  .diales { grid-template-columns: minmax(0, 1fr); gap: 0.8rem; }
  .dial { padding: 0.75rem 0.8rem; gap: 0.45rem; }
  .grande { font-size: 2.1rem; }
  .cancion-abrir { grid-template-columns: minmax(0, 1fr); }
  .biblio-cabeza .principal { padding: 0.75rem 1.1rem; }

  /* En el teléfono, los botones de reproducir quedan fijos abajo: siempre a la mano */
  .t-mover {
    position: fixed; z-index: 8; left: 0; right: 0; bottom: 0;
    justify-content: center; gap: 0.6rem;
    padding: 0.5rem max(0.75rem, env(safe-area-inset-right, 0px)) calc(0.5rem + env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgb(0 0 0 / 0.08);
  }
  .t-mover .ctl { min-height: 2.75rem; }
  .t-mover .ctl.sq { width: 2.75rem; }
  :root[data-fase="lista"] .marco { padding-bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Al tacto: teléfono y tablet ---------- */
@media (pointer: coarse) {
  /* Todo lo que se toca mide al menos 44 px, lo que pide un dedo */
  .ctl { min-height: 2.75rem; }
  .ctl.sq { width: 2.75rem; }
  .ctl.chico { min-height: 2.75rem; padding: 0.4rem 0.75rem; font-size: 0.86rem; }
  .ctl.chico.sq { width: 2.75rem; padding: 0; }
  .ficha { min-width: 2.75rem; min-height: 2.75rem; padding: 0.5rem 0.75rem; font-size: 0.86rem; }
  .icono, .cancion-acciones .icono { width: 2.75rem; height: 2.75rem; }
  .icono svg, .cancion-acciones .icono svg { width: 1.2rem; height: 1.2rem; }
  .enlace { display: inline-block; padding-block: 0.9rem; margin-block: -0.9rem; }
  .tramo { padding-block: 0.7rem; }
  .item-tocar { min-height: 2.75rem; justify-content: center; }
  /* Con letra de menos de 16 px, el iPhone agranda la página al escribir */
  input[type="text"], input[type="search"], textarea { font-size: max(16px, 1rem); }
  input[type="text"], input[type="search"] { min-height: 2.75rem; }
  input[type="range"] { --perilla: 28px; height: 2.75rem; }

  /* La onda: más alta, y los bordes del bucle con más sitio para agarrarlos */
  .onda { height: clamp(7.5rem, 24vh, 11rem); }
  .borde::before { left: -22px; right: -22px; }
  .borde em { padding: 0.34rem 0.5rem; font-size: 0.78rem; }

  /* El teclado de notas: teclas del ancho de un dedo; se recorre de lado */
  .teclado { min-width: 66rem; }
  .nota .tecla { height: 2.75rem; }
  .nota .nombre:not(:empty) { font-size: 0.7rem; }
}

/* En la tablet (y en el teléfono acostado), toda la fila de reproducción queda fija abajo */
@media (pointer: coarse) and (min-width: 36.01rem) {
  .transporte {
    position: fixed; z-index: 8; left: 0; right: 0; bottom: 0;
    flex-wrap: nowrap; gap: 0.5rem;
    padding: 0.5rem max(1rem, env(safe-area-inset-right, 0px), calc((100vw - 62rem) / 2)) calc(0.5rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px), calc((100vw - 62rem) / 2));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgb(0 0 0 / 0.08);
  }
  .tiempo { font-size: 1.15rem; }
  :root[data-fase="lista"] .marco { padding-bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)); }
}
/* …y si no es muy ancha, el botón de bucle se queda solo con su dibujo y todo va más junto */
@media (pointer: coarse) and (min-width: 36.01rem) and (max-width: 47.99rem) {
  .t-texto { display: none; }
  #bucle { width: 2.75rem; padding: 0; }
  .separador { margin-inline: 0.1rem; }
  .transporte, .t-mover, .t-bucle { gap: 0.35rem; }
}
/* …y más angosta todavía (un iPad con la pantalla dividida), el tiempo va sin el total */
@media (pointer: coarse) and (min-width: 36.01rem) and (max-width: 41.99rem) {
  .tiempo small { display: none; }
}
