:root {
  --bg: #fbfaf7; --sf: #ffffff; --tx: #1d2025; --mut: #6b7280; --bd: #e4e1da;
  --ac: #0a6ebd; --ch: #c2410c; --fs: 20px; color-scheme: light;
}
html[data-tema=oscuro] {
  --bg: #0e1014; --sf: #171a20; --tx: #eceff4; --mut: #8f98a8; --bd: #272c35;
  --ac: #58b7ff; --ch: #ffc857; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 820px; margin: 0 auto; min-height: 100vh; }

/* barra superior */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--bd); }
.bar h1 { flex: 1; margin: 0; font-size: 20px; }
.ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ttl b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl small { color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* botones */
.ib { min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px;
  background: transparent; font-size: 24px; line-height: 1; }
.ib:active, .btn:active { background: var(--bd); }
.ib.off { opacity: .25; }
.ib small { font-size: 13px; }
.btn { display: inline-block; padding: 10px 16px; border: 1px solid var(--bd); border-radius: 12px; background: var(--sf); font-weight: 600; }
.txt { border: 0; background: none; color: var(--mut); padding: 10px; }
.peligro { color: #d33; }
.chip { border: 1px solid var(--bd); border-radius: 999px; background: var(--sf); padding: 8px 14px; font-weight: 600; }
.chip.on { background: var(--ac); border-color: var(--ac); color: #fff; }
html[data-tema=oscuro] .chip.on { color: #0e1014; }

/* lista */
.acciones { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 12px 0; }
.acciones .btn { flex: 1; text-align: center; background: var(--ac); border-color: var(--ac); color: #fff; }
html[data-tema=oscuro] .acciones .btn { color: #0e1014; }
.busca { padding: 12px; }
.busca input { width: 100%; padding: 12px 14px; font-size: 17px; border: 1px solid var(--bd); border-radius: 12px; background: var(--sf); }
.lista { list-style: none; margin: 0; padding: 0 12px; }
.lista li { display: flex; align-items: center; border-bottom: 1px solid var(--bd); }
.lista .it { flex: 1; min-width: 0; padding: 14px 4px; display: flex; flex-direction: column; }
.lista .tt { font-size: 18px; font-weight: 600; }
.lista small { color: var(--mut); }
.lista .vacio { padding: 24px 4px; color: var(--mut); display: block; }
.star, .mv { width: 44px; height: 44px; border: 0; background: none; font-size: 24px; color: var(--mut); }
.mv { width: 36px; font-size: 20px; }
.star.on { color: var(--ch); }
.drag { width: 40px; align-self: stretch; display: flex; align-items: center; justify-content: center; color: var(--mut); font-size: 22px; touch-action: none; cursor: grab; user-select: none; }
.lista li.arr { background: var(--sf); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.star.on { background: var(--ch); color: #fff; border-radius: 50%; width: 36px; height: 36px; margin: 0 4px; font-size: 17px; font-weight: 800; }
html[data-tema=oscuro] .star.on { color: #0e1014; }
.ayuda-rep { padding: 4px 12px; font-size: 14px; color: var(--mut); }
.sig { display: flex; flex-direction: column; gap: 2px; margin: 0 16px; padding: 18px; border: 2px solid var(--ac); border-radius: 16px; background: var(--sf); color: var(--tx); text-align: left; }
.sig small { color: var(--mut); font-size: 13px; } .sig b { font-size: 22px; color: var(--ac); }
body.esc .sig b { font-size: 30px; }
.pie { padding: 24px 12px 48px; text-align: center; }

/* canción */
.letra { padding: 16px 16px 8px; font-size: var(--fs); line-height: 1.25; }
.letra .l { margin: 0 0 .45em; }
.letra .ch { color: var(--ch); font-weight: 700; margin-bottom: .6em; white-space: pre-wrap; }
.letra .ch b { font-weight: 800; }
.letra .sp { height: .6em; }
.letra .sec { margin: 1.1em 0 .5em; font-size: .62em; letter-spacing: .08em; color: var(--ac); border-bottom: 1px solid var(--bd); padding-bottom: .2em; }
.g { display: inline-block; white-space: nowrap; vertical-align: bottom; }
.s { display: inline-flex; flex-direction: column; vertical-align: bottom; }
.c { display: block; min-height: 1.25em; padding-right: .45em; color: var(--ch); font-weight: 800; white-space: pre; }
.t { display: block; white-space: pre; }
.t:empty::before { content: "\200b"; }
.fin { text-align: center; color: var(--mut); padding: 40px 0 130px; font-size: 14px; }

/* barra inferior */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 4px;
  max-width: 820px; margin: 0 auto; padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--sf) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--bd); }
.grp { display: flex; align-items: center; }
.tono { min-width: 76px; height: 44px; border: 0; background: none; font-size: 20px; font-weight: 800; color: var(--ch); }
.tono small { color: var(--mut); font-weight: 500; font-size: 12px; }
.play { background: var(--ac); color: #fff; width: 56px; border-radius: 28px; font-size: 22px; }
html[data-tema=oscuro] .play { color: #0e1014; }
.play:active { background: var(--ac); filter: brightness(.9); }

.dock { flex-wrap: wrap; justify-content: center; }
.dock .ib { min-width: 38px; }
.dock .tono { min-width: 64px; }
.dock .navrep { background: var(--bd); }

/* velocidad: aparece solo mientras corre el autoscroll */
.velbar { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 6; display: none; align-items: center; gap: 4px;
  background: var(--sf); border: 1px solid var(--bd); border-radius: 999px; padding: 2px 6px; box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.velbar.on { display: flex; }
.velbar .ib { font-size: 18px; min-width: 56px; }
.velbar span { font-size: 14px; color: var(--mut); white-space: nowrap; }
.velbar b { color: var(--tx); font-size: 18px; }
body.esc .velbar .ib { height: 56px; font-size: 22px; min-width: 70px; }
body.esc .velbar span { font-size: 16px; }

/* hojas y avisos */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.hoja { width: 100%; max-width: 520px; background: var(--sf); padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; gap: 14px; }
.hoja h3 { margin: 0; }
.hoja input[type=password] { padding: 12px; font-size: 17px; border: 1px solid var(--bd); border-radius: 12px; background: var(--bg); }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp2 { justify-content: space-between; }
.sp2 input[type=range] { flex: 1; max-width: 180px; }
.sp2 input[type=checkbox] { width: 24px; height: 24px; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 30;
  background: #222; color: #fff; padding: 10px 18px; border-radius: 999px; transition: .25s; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* editor */
.ed { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ed input, .ed textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--bd); border-radius: 12px; background: var(--sf); font-size: 17px; }
.ed textarea { min-height: 50vh; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 15px; line-height: 1.3; white-space: pre; overflow: auto; resize: vertical; }
.ayuda { background: var(--sf); border: 1px solid var(--bd); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--mut); }
.etq { color: var(--mut); font-size: 13px; margin: 6px 0 -6px; }
.split { display: grid; gap: 10px; }
@media (min-width: 900px) { #app { max-width: 1200px; } .split { grid-template-columns: 1fr 1fr; } .ed textarea { min-height: 70vh; } }

/* modo escenario: negro puro, letra grande, botones grandes, sin distracciones */
.solo-esc { display: none; }
.grande { width: 100%; padding: 14px; font-size: 18px; }
body.esc { --bg: #000; --sf: #0b0b0b; --tx: #fff; --bd: #2a2a2a; --ch: #ffd84a; --ac: #4cc9ff; color-scheme: dark; }
body.esc .bar { padding: 2px 8px; border: 0; background: #000; }
body.esc .bar .ib:not(:first-child), body.esc .bar .ttl small { display: none; }
body.esc .ttl b { font-size: 15px; color: var(--mut); }
body.esc .solo-esc { display: inline-flex; }
body.esc .dock { background: #000; border-top: 1px solid var(--bd); padding: 8px 6px max(8px, env(safe-area-inset-bottom)); }
body.esc .dock .ib { min-width: 54px; height: 60px; font-size: 30px; }
body.esc .dock .play { width: 72px; border-radius: 30px; }
body.esc .tono { height: 60px; font-size: 26px; min-width: 84px; }
body.esc .letra { line-height: 1.3; font-weight: 600; }
body.esc .letra .sec { font-size: .55em; background: var(--ac); color: #000; display: inline-block; padding: .15em .6em; border: 0; border-radius: 6px; }
body.esc .dock .grp:has(#am) { display: none; }
body.esc .fin { padding-bottom: 170px; }

@media print {
  .bar, .dock, .fin, #toast, .modal { display: none !important; }
  body { background: #fff; color: #000; } .letra { --ch: #000; padding: 0; }
  .letra .sec { color: #000; }
}
