:root {
  --bg: #15171c;
  --panel: #1f232b;
  --line: #333a46;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --accent: #4fb3ff;   /* colore principale: l'azzurro di "Segui il brano" (prima giallo) */
  --accent2: #4fb3ff;
  --danger: #e5534b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent2); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
header.top h1 { font-size: 22px; margin: 0; flex: 1; display: flex; align-items: center; gap: 8px; }
header.top .brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
header.top .brand img { width: 30px; height: 30px; }
header.top .sep { color: var(--muted); font-weight: 400; }
header.top nav a { margin-left: 12px; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

button, .btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent2); }
button.primary, .btn.primary { background: var(--accent); color: #08131f; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .4; }

input, select, textarea {
  background: #0f1115;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  width: 100%;
}
textarea { font-family: Menlo, Consolas, monospace; font-size: 14px; line-height: 1.45; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- Libreria ---------- */
.tvbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.tvbox code { color: var(--accent); font-size: 18px; }
.songs { list-style: none; padding: 0; margin: 0; }
.songs li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px; border-bottom: 1px solid var(--line);
}
.songs .info { flex: 1; min-width: 180px; }
.songs .title { font-weight: 600; }
.badge { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); margin-left: 6px; }

/* ---------- Editor ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.fields .full { grid-column: 1 / -1; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.preview { max-height: 75vh; overflow: auto; font-size: 18px; }
.ytwrap { aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.ytwrap iframe, .ytwrap > div { width: 100%; height: 100%; }
.help { font-size: 13px; color: var(--muted); }
.help code { color: var(--accent); }
@media (max-width: 800px) { .grid, .fields { grid-template-columns: 1fr; } }

/* ---------- Brano (comune a TV, anteprima, telecomando) ---------- */
.song .row { min-height: 1em; }
.song .line { margin: 0 0 .25em; }
.song .seg { display: inline-block; vertical-align: bottom; }
.song .ch { display: block; color: var(--accent); font-weight: 700; white-space: pre; padding-right: .45em; line-height: 1.15; }
.song .tx { display: block; white-space: pre; line-height: 1.2; }
.song .no-chords .ch { display: none; }
.song .chords-only .tx { display: none; }
.song .section {
  color: var(--accent2); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  font-size: .7em; margin: .9em 0 .3em;
}
.song .empty { height: .6em; }
.song .current .tx { color: #fff; }

/* ---------- Telecomando ---------- */
.remote { max-width: 560px; }
.ctrl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.ctrl button { padding: 16px 6px; font-size: 18px; }
.ctrl .big { grid-column: 1 / -1; font-size: 24px; padding: 20px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stepper .name { flex: 1; }
.stepper .val { min-width: 70px; text-align: center; font-size: 20px; font-weight: 700; color: var(--accent); }
.stepper button { width: 52px; height: 46px; font-size: 22px; padding: 0; }
.seg3 { display: flex; gap: 6px; }
.stepper .seg3 button { width: auto; padding: 0 10px; font-size: 15px; }
.seg3 button.on { border-color: var(--accent); color: var(--accent); }
.status { font-size: 14px; color: var(--muted); margin: 8px 0; }
.status .ok { color: #5fd38d; }
.status .err { color: var(--danger); }
.mini { font-size: 14px; max-height: 40vh; overflow: auto; margin-top: 12px; }

/* barra di salvataggio sempre visibile nell'editor */
.savebar {
  position: sticky; top: 0; z-index: 30; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--bg); padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}

/* colonna destra dell'editor (video, pulsanti, anteprima) sempre visibile */
.sidecol { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 72px); overflow-y: auto; }
.sidecol .preview { max-height: 55vh; }
@media (max-width: 800px) { .sidecol { position: static; max-height: none; } }

/* commento nel testo ("# nota"): promemoria, ignorato dalla sincronizzazione */
.song .note { font-size: .55em; font-style: italic; color: var(--muted); margin: .3em 0; }

/* accesso (passkey) */
.auth-box { max-width: 460px; margin: 30px auto; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 22px; }
.auth-box .auth-logo { width: 84px; height: 84px; border-radius: 20px; }
.auth-box h2 { margin: 12px 0 6px; }
.auth-box button.big { font-size: 18px; padding: 12px 20px; margin: 14px 0 6px; width: 100%; }
.auth-box label { display: block; text-align: left; margin-top: 10px; }
.auth-box input { width: 100%; margin-top: 4px; }

/* icone Font Awesome (al posto delle emoji, vedi icons.js) */
.ico { font-size: .95em; }
/* righe della libreria cliccabili */
.songs li.clickable { cursor: pointer; }
.songs li.clickable:hover { border-color: var(--accent); }
