/* =========================================================================
   Guitar Arranger: pensado para tocar con la guitarra en brazos y la
   pantalla a un metro. Tema oscuro unico; el ambar es el unico color de
   "lo que suena" (casilla, compas y acorde actuales).
   ========================================================================= */
:root {
  --bg: #141b24;
  --panel: #1d2733;
  --cell: #2c3440;
  --cell-hover: #364050;
  --text: #f2f2f2;
  --muted: #8d99a6;
  --chord: #f3ead6;
  --now: #ffb020;
  --now-ink: #1a1205;
  --now-soft: rgba(255, 176, 32, 0.45);
  --finger: #f3dfa6;
  --finger-ink: #141b24;
  --line: rgba(255, 255, 255, 0.09);
  --fill: rgba(255, 255, 255, 0.08);
  --danger: #ff6b5e;
  --now-text: #ffb020;               /* ambar como color de texto */
  --hover: rgba(255, 255, 255, 0.14);
  --pressed: rgba(255, 255, 255, 0.18);
  --popover: #253141;
  --scroll: rgba(255, 255, 255, 0.2);
  --bar-edge: rgba(255, 255, 255, 0.8);
  --lyric: #c4ccd5;
  --row-hover: rgba(255, 255, 255, 0.04);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
}
/* Tema claro (Ajustes > Tema): para tocar con mucha luz. "Auto" sigue al
   sistema. El ambar de fondo (lo que suena) es el mismo; el de texto, mas
   oscuro para que se lea sobre blanco. */
:root[data-theme="light"] {
  --bg: #eef1f5;
  --panel: #ffffff;
  --cell: #e3e8ee;
  --cell-hover: #d6dde6;
  --text: #121a24;
  --muted: #56616e;
  --chord: #1d2733;
  --now-soft: rgba(230, 150, 0, 0.4);
  --finger: #1d2733;
  --finger-ink: #ffffff;
  --line: rgba(0, 0, 0, 0.1);
  --fill: rgba(0, 0, 0, 0.06);
  --danger: #c62f22;
  --now-text: #985800;
  --hover: rgba(0, 0, 0, 0.08);
  --pressed: #ffffff;
  --popover: #ffffff;
  --scroll: rgba(0, 0, 0, 0.25);
  --bar-edge: rgba(0, 0, 0, 0.55);
  --lyric: #2b3440;
  --row-hover: rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #eef1f5;
    --panel: #ffffff;
    --cell: #e3e8ee;
    --cell-hover: #d6dde6;
    --text: #121a24;
    --muted: #56616e;
    --chord: #1d2733;
    --now-soft: rgba(230, 150, 0, 0.4);
    --finger: #1d2733;
    --finger-ink: #ffffff;
    --line: rgba(0, 0, 0, 0.1);
    --fill: rgba(0, 0, 0, 0.06);
    --danger: #c62f22;
    --now-text: #985800;
    --hover: rgba(0, 0, 0, 0.08);
    --pressed: #ffffff;
    --popover: #ffffff;
    --scroll: rgba(0, 0, 0, 0.25);
    --bar-edge: rgba(0, 0, 0, 0.55);
    --lyric: #2b3440;
    --row-hover: rgba(0, 0, 0, 0.04);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-anchor: none; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh; letter-spacing: -0.01em;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--now); outline-offset: 2px; }

.app-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #ffb020, #ff6a3d); color: #1a1205; font-weight: 800;
}

/* Botones: todos de al menos 48 px, para pulsarlos con la guitarra en brazos */
.btn {
  min-width: 48px; min-height: 48px; padding: 0 16px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--fill); color: var(--text); font-weight: 600; font-size: 0.92rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.icon { padding: 0; width: 48px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-accent { background: var(--now); color: var(--now-ink); }
.btn-accent:hover { background: #ffc04d; }
.btn-accent:disabled { opacity: 0.5; cursor: default; }

/* --- Portada y carga ----------------------------------------------------- */
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; min-height: 60px; }
/* Instalar la app: solo cuando el navegador lo permite (o en iPhone, con los pasos) */
.install-btn { margin-left: auto; min-height: 48px; padding: 0 16px; background: rgba(255, 176, 32, 0.16); color: var(--now-text); font-weight: 600; }
.install-hint { max-width: 1100px; margin: 0 auto; padding: 0 20px 12px; color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
.hero { text-align: center; padding: 6vh 0 10px; }
.hero-title {
  font-size: clamp(2.5rem, 7vw, 4.6rem); font-weight: 800; letter-spacing: -0.045em; line-height: 1.02; margin: 0 auto 14px;
}
.hero-title em { font-style: normal; color: var(--now-text); }
.hero-sub { color: var(--muted); font-size: clamp(1.05rem, 2.2vw, 1.3rem); line-height: 1.45; margin: 0 auto; max-width: 620px; }
.hero-form { max-width: 640px; margin: 30px auto 0; display: flex; gap: 10px; }
.field { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; }
.field svg { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.slot {
  width: 100%; min-height: 56px; padding: 0 18px 0 44px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--text); font-family: var(--font); font-size: 1rem;
}
.slot::placeholder { color: var(--muted); }
.slot:focus { outline: none; border-color: var(--now); box-shadow: 0 0 0 3px var(--now-soft); }
.hero-form .btn { min-height: 56px; padding: 0 26px; font-size: 1rem; }
/* Resultados de la busqueda por nombre */
.search-status { max-width: 640px; margin: 14px auto 0; color: var(--muted); font-size: 0.92rem; }
.results { max-width: 640px; margin: 14px auto 0; display: grid; gap: 6px; text-align: left; }
.result {
  display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 72px;
  padding: 6px; border: none; border-radius: 12px; background: none; color: var(--text); cursor: pointer; text-align: left;
}
.result:hover, .result:focus-visible { background: var(--panel); }
.result img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--panel); display: block; }
.result b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.result span { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot::-webkit-search-cancel-button { filter: invert(0.7); cursor: pointer; }
.result .ready { font-style: normal; font-weight: 700; color: var(--now-text); }
.shelf { margin: 48px auto 0; text-align: left; }
.shelf h2 { font-size: 0.85rem; font-weight: 700; color: var(--muted); margin: 0 0 14px; letter-spacing: 0.02em; text-transform: uppercase; }
.example-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.example, .recent {
  text-align: left; border: none; background: none; padding: 0; cursor: pointer; color: var(--text); min-height: 48px;
}
.example img, .recent img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-radius: 12px;
  background: var(--panel); transition: transform 0.25s ease;
}
.example:hover img, .recent:hover img { transform: scale(1.03); }
.example b, .recent b { display: block; margin-top: 10px; font-size: 0.98rem; font-weight: 600; }
.example span { color: var(--muted); font-size: 0.86rem; }
.recent-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
/* Portada: lo que puedes hacer, creditos y privacidad */
.features { list-style: none; margin: 28px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.features li { padding: 12px 14px; border-radius: 12px; background: var(--panel); color: var(--muted); font-size: 0.9rem; line-height: 1.35; }
.features b { color: var(--text); }
.site-footer { margin: 28px 0 8px; color: var(--muted); font-size: 0.8rem; line-height: 1.5; text-align: center; }
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--now-text); }
.recent-setup { display: block; margin-top: 2px; color: var(--now-text); font-size: 0.78rem; font-weight: 600; }
.recent b { font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.loading { display: grid; place-items: center; gap: 14px; padding: 10vh 20px; text-align: center; color: var(--muted); }
.loading-thumb { width: min(360px, 80vw); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; background: var(--panel); }
.loading-thumb:not([src]) { display: none; }
.loading-title { color: var(--text); font-weight: 700; font-size: 1.05rem; max-width: 520px; }
.loading-progress { width: min(360px, 80vw); height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.loading-progress > div { height: 100%; width: 0; background: var(--now); border-radius: 4px; transition: width 0.3s linear; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--fill); border-top-color: var(--now);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  max-width: 640px; margin: 16px auto 0; border-radius: 12px; padding: 13px 16px;
  background: rgba(255, 107, 94, 0.14); color: var(--danger); font-weight: 500;
}

/* --- Pantalla de la cancion -----------------------------------------------
   Rejilla a pantalla completa (nunca desplaza la pagina; solo la rejilla
   de compases tiene scroll propio):
     ordenador/tablet:  barra / [ahora+siguiente | video] / [.. | controles] / rejilla
     movil:             barra / video / ahora+siguiente / rejilla / controles
   El video mide al menos 200 px de alto (minimo de YouTube) y su columna se
   ajusta a 16:9 para no dejar franjas negras. */
.song {
  --stage-h: max(290px, 44vh);
  --transport-h: 80px;
  --video-h: max(200px, min(calc(var(--stage-h) - var(--transport-h)), calc(48vw * 9 / 16)));
  --video-w: calc(var(--video-h) * 16 / 9);
  position: fixed; inset: 0; height: 100dvh;
  /* Instalada en el movil: respetar la muesca y la barra de inicio */
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid; gap: 10px 14px;
  grid-template-columns: minmax(0, 1fr) var(--video-w);
  grid-template-rows: auto var(--video-h) var(--transport-h) minmax(0, 1fr);
  grid-template-areas: "bar bar" "now video" "now transport" "main main";
}

/* Barra de la cancion */
.song-bar { grid-area: bar; display: flex; align-items: center; gap: 8px; min-width: 0; }
.home-link { display: grid; place-items: center; width: 48px; height: 48px; flex: none; text-decoration: none; }
.song-id { flex: 1; min-width: 0; padding: 0 4px; }
.song-id h1 { margin: 0; font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-id p { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tuning-warn { color: var(--now-text); font-weight: 600; cursor: help; }
.capo { display: flex; align-items: center; gap: 4px; flex: none; }
.capo-lbl { font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.capo b { min-width: 26px; text-align: center; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.suggest { background: rgba(255, 176, 32, 0.16); color: var(--now-text); }
.suggest:hover { background: rgba(255, 176, 32, 0.26); }

/* Ahora / Siguiente: lo que se mira de lejos */
/* .nownext es el contenedor que se mide; .nownext-in se recoloca segun su
   tamano (un contenedor no puede cambiarse a si mismo con @container). */
.nownext { grid-area: now; container-type: size; min-width: 0; background: var(--panel); border-radius: var(--radius); }
.nownext-in { height: 100%; display: grid; grid-template-columns: 58fr 42fr; gap: 10px 18px; padding: 12px 16px; }
.now, .next { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-radius: 10px; }
.tag { display: flex; align-items: center; gap: 10px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); min-height: 20px; }
.now .tag { color: var(--now-text); }
/* Seccion que suena (Estrofa, Estribillo...), junto al pulso */
.now .tag { min-width: 0; }
.now-sec { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.chord-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: flex-start; gap: clamp(10px, 4cqw, 44px); }
/* El nombre y "cambia en N" no se dejan aplastar por el diagrama (el teclado del piano es ancho) */
.next-name { display: flex; flex-direction: column; gap: 8px; min-width: min(5em, 45%); flex: 1 1 0; }
/* Los diagramas se encogen si no caben a lo ancho (ventana alta: crecen con
   la altura del panel y se salian de su columna). */
.now-diagram, .next-diagram { flex: 0 1 auto; min-width: 0; }
.now-chord {
  font-size: min(120px, 30cqh, 14cqw); font-weight: 800; letter-spacing: -0.045em; line-height: 1;
  white-space: nowrap; color: var(--text);
}
.next-chord {
  font-size: min(66px, 16.5cqh, 7.7cqw); font-weight: 700; letter-spacing: -0.03em; line-height: 1;
  white-space: nowrap; color: var(--chord);
}
.now-diagram svg { height: min(230px, 62cqh); width: auto; max-width: 100%; display: block; color: var(--text); }
/* Tocar un diagrama hace sonar el acorde */
[data-chord] svg { cursor: pointer; }
[data-chord]:active svg { transform: scale(0.97); }
.next-diagram svg { height: min(160px, 43cqh); width: auto; max-width: 100%; display: block; color: var(--muted); }
/* Puede ir en dos lineas: si no cabe, nunca debe salirse sobre el diagrama. */
.countdown { color: var(--text); font-weight: 600; font-size: clamp(0.8rem, 4.5cqh, 1.05rem); line-height: 1.2; min-height: 1.2em; }
.next { padding: 0 8px; margin: 0 -8px; transition: box-shadow 0.15s; }
.next.soon { box-shadow: inset 0 0 0 2px var(--now); }
.next.soon .countdown { color: var(--now-text); }
/* Se acerca otra seccion: "-> Estribillo" */
.next-sec { min-height: 1.2em; margin-top: 2px; color: var(--now-text); font-weight: 700; font-size: clamp(0.72rem, 4cqh, 0.95rem); white-space: nowrap; }
.now-progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 8px; flex: none; }
.now-progress > div { height: 100%; width: 0; background: var(--now); border-radius: 3px; }
.pulse { display: flex; gap: 6px; }
.pulse i { width: 11px; height: 11px; border-radius: 50%; background: var(--fill); }
.pulse i.on { background: var(--now); }
/* Panel estrecho y alto (tablet en vertical): uno encima del otro */
@container (max-width: 520px) and (min-height: 260px) {
  .nownext-in { grid-template-columns: 1fr; grid-template-rows: 1.25fr 1fr; }
  .now-chord { font-size: min(110px, 20cqh, 24cqw); }
  .next-chord { font-size: min(60px, 11cqh, 13cqw); }
  .now-diagram svg { height: min(200px, 36cqh); }
  .next-diagram svg { height: min(140px, 26cqh); }
}

/* Video y controles */
.video { grid-area: video; position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-wrap { position: absolute; inset: 0; }
.video-wrap iframe, .video-wrap > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; text-align: center; background: var(--panel);
}
.embed-fallback p { color: var(--muted); font-size: 0.82rem; margin: 0; max-width: 300px; }
.embed-fallback a { background: var(--now); color: var(--now-ink); font-weight: 700; padding: 12px 18px; border-radius: 999px; text-decoration: none; }
.transport { grid-area: transport; display: flex; flex-direction: column; justify-content: center; gap: 4px; position: relative; min-width: 0; }
.seek-row { display: flex; align-items: center; gap: 10px; }
.seek-row input { flex: 1; min-width: 0; accent-color: var(--now); cursor: pointer; }
.time { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.buttons { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.buttons .play { width: 56px; min-height: 56px; background: var(--text); color: var(--bg); }
.buttons .play:hover { background: #fff; }
.speed-btn, .loop-btn { padding: 0 12px; font-variant-numeric: tabular-nums; }
.loop-btn[aria-pressed="true"] { background: var(--now); color: var(--now-ink); }
.menu {
  position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 20; min-width: 150px; padding: 6px;
  background: var(--popover); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: grid; gap: 2px;
}
.menu button {
  min-height: 48px; border: none; border-radius: 8px; background: none; cursor: pointer; text-align: left;
  padding: 0 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.menu button:hover { background: var(--fill); }
.menu button[aria-pressed="true"] { color: var(--now-text); }
.menu .trainer { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; white-space: normal; max-width: 210px; line-height: 1.3; }
.menu .trainer::before { content: '☐ '; }
.menu .trainer[aria-pressed="true"]::before { content: '☑ '; }

/* Rejilla de compases */
.main { grid-area: main; min-height: 0; min-width: 0; }
.grid-scroll { height: 100%; overflow-y: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.row { display: flex; align-items: stretch; gap: 6px; margin-bottom: 5px; }
.num { width: 22px; flex: none; font-size: 0.7rem; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; }
.bars { flex: 1; min-width: 0; display: flex; gap: 5px; }
.bar { display: grid; gap: 3px; min-width: 0; border-radius: 4px; }
.bar.current { box-shadow: 0 0 0 2px var(--now-soft); }
.cell {
  height: clamp(52px, 7.5vh, 72px); background: var(--cell); border-radius: 3px; padding: 4px 8px; min-width: 0;
  color: var(--chord); cursor: pointer; overflow: hidden; display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
}
.cell:first-child { box-shadow: inset 2px 0 0 var(--bar-edge); }
.cell:hover { background: var(--cell-hover); }
.cell b { font-size: 1.3rem; font-weight: 600; white-space: nowrap; }
.cell i { font-style: normal; font-size: 0.8rem; color: var(--muted); }
.cell.active { background: var(--now); color: var(--now-ink); }
.cell.active i { color: rgba(26, 18, 5, 0.7); }
.cell.looped { box-shadow: inset 0 -4px 0 #4da3ff; }
.cell.looped:first-child { box-shadow: inset 2px 0 0 var(--bar-edge), inset 0 -4px 0 #4da3ff; }

/* Vista Linea: los acordes pasan de derecha a izquierda bajo una raya fija */
.line { height: 100%; display: flex; align-items: center; }
/* Una vista a la vez: Compases, Letra o Linea */
.main.view-grid .line, .main.view-grid .lyrics-pane,
.main.view-line .grid-scroll, .main.view-line .lyrics-pane,
.main.view-lyrics .grid-scroll, .main.view-lyrics .line { display: none; }

/* Vista Letra (ordenador/tablet): letra a la izquierda, todo lo demas a la derecha */
@media (min-width: 700px) {
  .song.view-lyrics {
    grid-template-rows: auto var(--video-h) var(--transport-h) minmax(0, 1fr);
    grid-template-areas: "bar bar" "main video" "main transport" "main now";
  }
}
/* Tablet en vertical: arriba el panel Ahora y el video (como en Compases) y
   la letra a todo lo ancho debajo; en una columna los versos se partian. */
@media (min-width: 700px) and (orientation: portrait) {
  .song.view-lyrics { grid-template-areas: "bar bar" "now video" "now transport" "main main"; }
}

/* Vista Letra: el panel Ahora/Siguiente va compacto a la derecha; el
   diagrama del siguiente, algo mas pequeno, deja sitio a "cambia en N". */
.song.view-lyrics .next-diagram svg { height: min(100px, 30cqh); }
.song.view-lyrics .countdown { font-size: 0.78rem; }

/* --- Selector de vista en la barra --- */
.views button { display: inline-flex; align-items: center; gap: 6px; }
.views svg { width: 18px; height: 18px; flex: none; }
#chordsBtn svg { width: 20px; height: 20px; }
.sg-long { white-space: pre; }
/* Barra justa (portatil, tablet): iconos con el nombre debajo y botones solo icono */
@media (max-width: 1199px) {
  #otherBtn { padding: 0; width: 48px; font-size: 0; gap: 0; }
  #chordsBtn { padding: 0; width: 48px; }
  #chordsCount, .sg-long { display: none; }
  .views button { flex-direction: column; gap: 1px; padding: 0 5px; font-size: 0.62rem; min-width: 52px; }
}

/* --- Letra con los acordes encima de las palabras --- */
.lyrics-pane { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.lyrics-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px 6px; min-height: 52px; }
.lyrics-info { color: var(--muted); font-size: 0.8rem; line-height: 1.3; min-width: 0; }
.lyrics-info.warn { color: var(--now-text); }
.lyrics-offset b { min-width: 52px; font-size: 0.9rem; }
.lyrics-scroll { flex: 1; min-height: 0; overflow-y: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
/* --text-scale: Ajustes > Tamano de la letra (para leer de lejos, en un atril) */
.lyrics { max-width: 900px; margin: 0 auto; padding: 0 6px 45vh; font-size: calc(clamp(1.05rem, 2.7vh, 1.5rem) * var(--text-scale, 1)); }
.lyr {
  padding: 4px 12px 8px; margin: 2px 0; border-radius: 10px; cursor: pointer; line-height: 1.2;
  color: var(--lyric); transition: background 0.15s, opacity 0.2s;
}
.lyr:hover { background: var(--row-hover); }
.lyr.current { background: var(--panel); color: var(--text); box-shadow: inset 4px 0 0 var(--now); }
.lyr.past { opacity: 0.5; }
.w { display: inline-block; position: relative; padding-top: 1.3em; white-space: pre; vertical-align: bottom; }
.chs { position: absolute; top: 0; left: 0; display: flex; gap: 0.35em; white-space: nowrap; }
.ch { font-weight: 700; font-size: 0.85em; color: var(--chord); padding: 0 3px; border-radius: 4px; line-height: 1.35; }
.ch.now { background: var(--now); color: var(--now-ink); }
.ch { cursor: pointer; }
.ch:hover { box-shadow: inset 0 -2px 0 var(--now-soft); }
.chord-pop {
  position: fixed; z-index: 45; width: 150px; padding: 8px 8px 6px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.chord-pop b { display: block; font-size: 1.25rem; color: var(--chord); margin-bottom: 2px; }
.chord-pop svg { width: 100%; height: auto; max-height: 170px; color: var(--text); }
.inst { color: var(--muted); padding-top: 8px; }
.inst .inst-name { font-size: 0.62em; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-right: 10px; }
.inst .ch { display: inline-block; margin: 0 0.4em 4px 0; }
/* Secciones: rotulo encima del primer verso; el estribillo, con una raya */
.lyr.sec-start { margin-top: 0.9em; }
.lyr.sec-start::before {
  content: attr(data-sec); display: block; margin-bottom: 0.25em; color: var(--muted);
  font-size: 0.6em; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.lyr.in-chorus:not(.current) { box-shadow: inset 2px 0 0 var(--now-soft); }
.lyr.sec-start.in-chorus::before { color: var(--now-text); }
/* Boton de 48 px para el dedo; el texto abajo, pegado a su fila, y el
   hueco de arriba separa las secciones. */
.sec-row {
  display: flex; align-items: flex-end; gap: 10px; margin: 0 0 0 28px; padding: 0 0 6px; min-height: 48px;
  background: none; border: 0; font: inherit; color: var(--muted); line-height: 1.2; cursor: pointer;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.sec-row:first-child { margin-top: 0; }
.sec-row.sec-chorus { color: var(--now-text); }
.sec-loop { font-weight: 600; letter-spacing: 0.04em; opacity: 0; transition: opacity 0.15s; color: var(--muted); }
.sec-row:hover .sec-loop, .sec-row:focus-visible .sec-loop { opacity: 1; }
.sec-row.looping .sec-loop { opacity: 1; color: #4da3ff; }
.sec-row.looping .sec-name { color: #4da3ff; }
@media (hover: none) { .sec-loop { opacity: 0.7; } }
.lyrics-empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 1rem; }
.lyrics-empty .btn { margin-top: 14px; }
.timeline {
  position: relative; flex: 1; height: 126px; overflow: hidden; cursor: pointer;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
}
.track { position: absolute; top: 0; left: 0; height: 100%; will-change: transform; }
.tl-chord { position: absolute; top: 26px; height: 64px; padding: 0 2px; }
/* Secciones encima de la cinta */
.tl-sec {
  position: absolute; top: 4px; padding-left: 5px; border-left: 2px solid currentColor; line-height: 16px; white-space: nowrap;
  color: var(--muted); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.tl-sec.sec-chorus { color: var(--now-text); }
.tl-box {
  height: 100%; border-radius: 4px; background: var(--cell); color: var(--chord);
  display: flex; align-items: center; padding-left: 10px; overflow: hidden; white-space: nowrap;
  font-size: 1.3rem; font-weight: 600;
}
.tl-chord.narrow .tl-box { padding-left: 5px; font-size: 0.9rem; }
.tl-chord.past .tl-box { opacity: 0.45; }
.tl-chord.current .tl-box { background: var(--now); color: var(--now-ink); }
.tl-tick { position: absolute; bottom: 10px; width: 1px; height: 6px; background: var(--muted); opacity: 0.5; }
.tl-tick.down { width: 2px; height: 13px; opacity: 0.95; }
.playhead { position: absolute; top: 2px; bottom: 2px; left: 25%; width: 3px; margin-left: -1px; border-radius: 3px; background: var(--text); pointer-events: none; }

/* Ajustes: panel desplegable bajo el boton de la rueda */
.popover {
  position: fixed; top: 66px; right: 12px; z-index: 30; width: min(380px, calc(100vw - 20px));
  max-height: calc(100dvh - 80px); overflow-y: auto; padding: 16px;
  background: var(--popover); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  display: grid; gap: 14px;
}
.popover h2, .sheet h2 { margin: 0; font-size: 1.05rem; }
.share-btn { width: 100%; justify-content: center; background: rgba(255, 176, 32, 0.16); color: var(--now-text); }
.share-btn:hover { background: rgba(255, 176, 32, 0.26); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.9rem; font-weight: 600; }
/* Compartir e Imprimir, lado a lado */
.set-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.set-actions .share-btn { padding-left: 8px; padding-right: 8px; }
@media (max-width: 420px) { .set-actions .share-btn { font-size: 0.85rem; gap: 5px; padding-left: 4px; padding-right: 4px; } }
/* Copia de seguridad */
.backup-btns { display: flex; gap: 8px; }
.backup-btns .btn { min-height: 48px; cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Grupos de Ajustes: Acordes / Para tocar */
.set-group {
  margin: 8px 0 -2px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.set-row.wrap-row { flex-wrap: wrap; }
.set-row small { flex-basis: 100%; color: var(--muted); font-weight: 400; font-size: 0.8rem; line-height: 1.35; }
.seg { display: flex; background: var(--fill); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  min-height: 48px; min-width: 48px; padding: 0 12px; border: none; border-radius: 9px; background: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 0.85rem;
}
.seg button[aria-pressed="true"] { background: var(--pressed); color: var(--text); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.keys summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; min-height: 48px; display: flex; align-items: center; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 4px 0 8px; font-size: 0.85rem; }
.keys dt { font-weight: 700; color: var(--now-text); white-space: nowrap; }
.keys dd { margin: 0; color: var(--text); }
.keys p { margin: 0; color: var(--muted); font-size: 0.8rem; }

/* Hoja con todos los acordes de la cancion */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(5, 8, 12, 0.66); display: grid; place-items: center; padding: 16px; }
.sheet-card {
  width: min(960px, 100%); max-height: min(86dvh, 100%); overflow-y: auto; padding: 16px 18px 20px;
  background: var(--panel); border-radius: 18px; border: 1px solid var(--line);
}
.sheet-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.sheet-item { background: var(--cell); border-radius: 12px; padding: 10px 6px 8px; text-align: center; }
.sheet-item b { display: block; font-size: 1.3rem; margin-bottom: 4px; color: var(--chord); }
.sheet-item svg { width: 100%; height: auto; max-height: 170px; color: var(--text); }
/* Esquema de la cancion: progresion de cada seccion */
.scheme:empty { display: none; }
.scheme { margin-bottom: 14px; }
.scheme h3 { margin: 0 0 4px; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.scheme-row { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.scheme-row b { flex: none; min-width: 96px; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }
.scheme-row b.sec-chorus { color: var(--now-text); }
.scheme-row span { color: var(--chord); font-weight: 700; font-size: 1.05rem; word-spacing: 0.25em; line-height: 1.5; }
.scheme-row small, .scheme-row i { color: var(--muted); font-weight: 600; font-style: normal; }
/* Corregir acorde */
.sheet-hint { margin: -4px 0 10px; color: var(--muted); font-size: 0.82rem; }
/* Piano: teclado con las notas del acorde; sin cejilla ni afinador */
.piano .pk-w { fill: #f6f6f6; stroke: #2a2a2a; stroke-width: 1; }
.piano .pk-b { fill: #1d1d1d; stroke: #111; stroke-width: 1; }
.piano .pk-w.on, .piano .pk-b.on { fill: var(--now); }
.is-piano #songBar .capo, .is-piano #suggestBtn, .is-piano #tunerBtn { display: none !important; }

/* Problemas con la letra */
.report-btn { flex: none; color: var(--muted); }
.report-card { width: min(480px, 100%); }
.report-reasons { display: grid; gap: 6px; margin-bottom: 12px; }
.report-reasons label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; background: var(--cell); cursor: pointer; }
.report-reasons input { accent-color: var(--now); width: 18px; height: 18px; }
.report-help { margin: 0 0 8px; color: var(--muted); font-size: 0.88rem; }
.report-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.report-fields input {
  min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--cell); color: var(--text); font: inherit; min-width: 0;
}
.report-msg { min-height: 1.2em; margin: 10px 0 0; color: var(--now-text); font-weight: 600; font-size: 0.9rem; line-height: 1.4; }

/* Notas personales de la cancion */
.notes-box { display: block; margin: 0 0 14px; }
.notes-box span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.notes-box textarea {
  width: 100%; min-height: 64px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--cell); color: var(--text); font: inherit; font-size: 0.95rem; line-height: 1.4; resize: vertical;
}
.edits-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; color: var(--now-text); font-size: 0.88rem; font-weight: 600; }
.edit-card { width: min(520px, 100%); }
.edit-help { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.edit-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.edit-grid.quals { grid-template-columns: repeat(4, 1fr); }
.edit-grid button {
  min-height: 48px; border: 0; border-radius: 10px; background: var(--cell); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
.edit-grid button[aria-pressed="true"] { background: var(--now); color: var(--now-ink); }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.btn.primary { background: var(--now); color: var(--now-ink); font-weight: 700; padding: 0 20px; }
.cell.edited b::after { content: ' ✎'; font-size: 0.6em; opacity: 0.75; }

.voicing-btn {
  width: 100%; min-height: 48px; margin-top: 4px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--fill); color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 600;
}
.voicing-btn:hover { color: var(--text); }

/* --- Afinador --- */
.tuner-card { width: min(440px, 100%); text-align: center; --tuned: #3ddc84; }
.tuner-ref { justify-content: center; }
.tuner-ref button { flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.tuner-ref small { font-size: 0.75rem; font-weight: 500; opacity: 0.8; }
.tuner-note { font-size: clamp(64px, 16vh, 96px); font-weight: 800; line-height: 1; margin: 14px 0 6px; }
/* Semicirculo de -50 a +50 cents con una marca en el centro */
.tuner-meter {
  position: relative; width: 220px; height: 112px; margin: 0 auto; overflow: hidden;
  border: 2px solid var(--line); border-bottom: 0; border-radius: 112px 112px 0 0;
}
.tuner-meter::before {
  content: ''; position: absolute; left: 50%; top: 0; width: 3px; height: 16px; transform: translateX(-50%);
  background: var(--tuned); border-radius: 2px;
}
.tuner-needle {
  position: absolute; left: 50%; bottom: 0; width: 3px; height: 100px; border-radius: 2px;
  background: var(--muted); opacity: 0.4; transform: translateX(-50%); transform-origin: 50% 100%; transition: transform 0.12s, background 0.12s;
}
.listening .tuner-needle { background: var(--now); opacity: 1; }
.tuner-cents { min-height: 1.4em; margin: 10px 0 14px; color: var(--muted); font-weight: 600; }
.tuner-strings { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.tuner-strings span {
  min-width: 48px; min-height: 48px; padding: 4px; border-radius: 10px; background: var(--cell); color: var(--muted);
  font-weight: 700; display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
}
.tuner-strings small { font-size: 0.65rem; font-weight: 600; }
.tuner-strings .on { background: var(--now); color: var(--now-ink); }
.in-tune .tuner-needle, .in-tune .tuner-strings .on { background: var(--tuned); }
.in-tune .tuner-note, .in-tune .tuner-cents { color: var(--tuned); }
.tuner-msg { min-height: 1em; margin: 12px 0 0; color: var(--now-text); font-size: 0.9rem; line-height: 1.4; }

/* Aviso breve (bucle) */
.hint {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 35; max-width: calc(100vw - 24px);
  padding: 12px 18px; border-radius: 12px; background: #2f3d4f; color: var(--text); font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); text-align: center;
  pointer-events: none;   /* solo informa: no debe tapar ni recoger toques (cerraba Ajustes) */
}

/* --- Movil en horizontal (poca altura): controles abajo a todo el ancho --- */
@media (max-height: 500px) and (min-width: 700px) {
  /* Vista Linea: solo queda una franja de unos 56 px para la cinta */
  .timeline { height: 100%; }
  .tl-chord { top: 3px; height: calc(100% - 20px); }
  .tl-sec { display: none; }   /* la seccion ya se ve en el panel Ahora */
  .tl-tick { bottom: 3px; }
  .tl-tick.down { height: 10px; }
  .song {
    --video-h: 200px; --video-w: 356px;
    grid-template-rows: auto var(--video-h) minmax(0, 1fr) auto;
    grid-template-areas: "bar bar" "now video" "main main" "transport transport";
    gap: 6px 12px; padding: 6px 12px 6px;
  }
  .transport { flex-direction: row; align-items: center; gap: 14px; }
  .views button { flex-direction: row; font-size: 0; gap: 0; min-width: 48px; padding: 0; }
  .song.view-lyrics { grid-template-areas: "bar bar" "main video" "main ." "transport transport"; }
  .song.view-lyrics .nownext { display: none; }
  /* Sin sitio para la barra de la letra: solo los versos (el desfase se ajusta con mas altura). */
  .lyrics-bar { display: none; }
  .lyr { padding: 2px 10px 4px; }
  .seek-row { flex: 1; }
  .cell { height: 46px; }
  .seg { padding: 0; }
  .seg button { min-height: 48px; }
}

/* --- Movil en vertical ---------------------------------------------------- */
@media (max-width: 699px) {
  .song {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto clamp(128px, 18vh, 170px) minmax(0, 1fr) auto;
    grid-template-areas: "bar" "video" "now" "main" "transport";
    gap: 8px; padding: 6px 10px 8px;
  }
  .video { aspect-ratio: 16 / 9; border-radius: 10px; }
  .song-bar { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto 48px 48px; grid-template-areas: "home id id chords settings" "capo capo views views views"; gap: 4px 6px; }
  .views { grid-area: views; justify-self: end; }
  .views button { min-width: 50px; padding: 0 2px; font-size: 0.6rem; }
  .suggest { padding: 0 10px; }
  .capo-lbl { display: none; }
  .lyrics-bar { min-height: 50px; }
  .home-link { grid-area: home; }
  .song-id { grid-area: id; }
  #chordsBtn { grid-area: chords; }
  #settingsBtn { grid-area: settings; }
  .capo { grid-area: capo; }
  #otherBtn { display: none; }
  .nownext-in { padding: 8px 12px; gap: 6px 12px; }
  .now-chord { font-size: min(64px, 34cqh, 15cqw); }
  .next-chord { font-size: min(36px, 19cqh, 8.5cqw); }
  .now-diagram svg { height: min(150px, 66cqh); }
  .next-diagram svg { height: min(110px, 50cqh); }
  .tag { font-size: 0.7rem; min-height: 16px; }
  .num { width: 16px; }
  .sec-row { margin-left: 22px; }
  .cell { padding: 3px 5px; }
  .cell b { font-size: 1.05rem; }
  .cell i { font-size: 0.72rem; }
  .buttons { justify-content: center; gap: 8px; }
  .buttons .btn { min-height: 56px; }
  .buttons .btn.icon { width: 56px; }
  .example-row { grid-template-columns: 1fr; max-width: 420px; margin: 0 auto; }
  .recent-row { grid-template-columns: repeat(2, 1fr); }
  .hero-form { flex-direction: column; }
}

/* --- Cancionero impreso: tinta negra sobre blanco, solo lo que sirve en papel --- */
.print-sheet { display: none; }
@media print {
  @page { margin: 14mm 12mm; }
  html, body { background: #fff !important; color: #000; min-height: 0; }
  body > *:not(#printSheet) { display: none !important; }
  .print-sheet {
    display: block; color: #000; font-size: 11pt;
    --text: #000; --chord: #000; --muted: #555; --finger: #000; --finger-ink: #fff;
    --cell: #fff; --now: #000; --now-soft: #999; --line: #ccc;
  }
  .print-sheet h1 { margin: 0 0 2pt; font-size: 18pt; }
  .print-meta { margin: 0 0 10pt; color: #444; }
  .print-chords { display: grid; grid-template-columns: repeat(auto-fill, minmax(64pt, 1fr)); gap: 6pt; margin-bottom: 12pt; }
  .print-chords .sheet-item { background: none; border: 1px solid #ccc; border-radius: 6pt; padding: 4pt 2pt; break-inside: avoid; }
  .print-chords .sheet-item b { color: #000; font-size: 11pt; }
  .print-chords svg { max-height: 86pt; color: #000; }
  .print-sheet .lyrics { max-width: none; padding: 0; font-size: 11.5pt; }
  .print-sheet .lyr { color: #000; padding: 0 0 2pt; margin: 0; border-radius: 0; opacity: 1; box-shadow: none; break-inside: avoid; }
  .print-sheet .lyr.in-chorus { border-left: 2px solid #999; padding-left: 6pt; }
  .print-sheet .lyr.sec-start { margin-top: 10pt; }
  .print-sheet .lyr.sec-start::before { color: #000; }
  .print-sheet .ch { color: #000; background: none; }
  .print-sheet .inst { color: #444; }
  .print-sheet .sec-row { color: #000; min-height: 0; padding-top: 8pt; }
  .print-sheet .sec-loop { display: none; }
  .print-sheet .row { break-inside: avoid; }
  .print-sheet .cell { height: 30pt; background: #fff; border: 1px solid #bbb; color: #000; box-shadow: none; }
  .print-sheet .cell i { color: #555; }
  .print-foot { margin-top: 14pt; color: #888; font-size: 8pt; }
  .print-notes { margin: 0 0 12pt; padding-left: 8pt; border-left: 3px solid #999; color: #000; white-space: pre-wrap; }
  /* Piano en papel: tarjetas mas anchas y las teclas marcadas en gris (el ambar sale negro) */
  .print-chords.piano-chords { grid-template-columns: repeat(auto-fill, minmax(130pt, 1fr)); }
  .print-sheet .piano .pk-w.on, .print-sheet .piano .pk-b.on { fill: #9a9a9a; }
  .print-sheet .scheme-row { border-color: #ccc; }
  .print-sheet .scheme-row b, .print-sheet .scheme-row span { color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
