:root {
  --bg: #0e1116; --bg2: #171b22; --bg3: #262c36; --fg: #f1ede4; --muted: #9a9fa8;
  --gold: #c9a45c; --gold2: #e6c98a; --teal: #4fb7a8; --q: #e8a33d; --qbg: rgba(232, 163, 61, .13);
  --err: #ef7a6f; --ok: #5fc59a; --r: 14px;
  --line: rgba(201, 164, 92, .18);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  /* patrón geométrico (estrella de 8 puntas) muy sutil */
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23c9a45c' stroke-opacity='.05'%3E%3Cpath d='M28 6l6 16 16 6-16 6-6 16-6-16-16-6 16-6z'/%3E%3Crect x='17' y='17' width='22' height='22' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif; }
body { padding-top: calc(52px + var(--safe-t)); padding-bottom: calc(64px + var(--safe-b)); }
body.has-player { padding-bottom: calc(176px + var(--safe-b)); }
button, select, input, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }

#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(52px + var(--safe-t));
  padding: var(--safe-t) 12px 0; display: flex; align-items: center; gap: 8px;
  background: rgba(17, 24, 39, .96); border-bottom: 1px solid var(--bg3); backdrop-filter: blur(8px); }
#topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#offline { font-size: 12px; color: var(--q); border: 1px solid var(--q); border-radius: 99px; padding: 2px 8px; }

#tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  padding-bottom: var(--safe-b); background: var(--bg2); border-top: 1px solid var(--bg3); }
#tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: 20px; }
#tabbar a span { display: block; font-size: 11px; }
#tabbar a.on { color: var(--gold); }

main { max-width: 980px; margin: 0 auto; padding: 12px; }
.icon-btn { background: none; border: 0; font-size: 24px; padding: 6px 10px; cursor: pointer; color: var(--fg); }
.icon-btn.big { font-size: 28px; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: #111; }
.btn { background: var(--gold); color: #111; border: 0; border-radius: var(--r); padding: 12px 16px; font-weight: 600; cursor: pointer; }
.btn.sec { background: var(--bg3); color: var(--fg); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn:disabled { opacity: .5; }
.chip { background: var(--bg3); color: var(--fg); border: 0; border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--teal); color: #111; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

input[type=text], input[type=search], input[type=password], input[type=url], input[type=date], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--bg3); border-radius: var(--r); padding: 12px; }
textarea { min-height: 70px; }
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
.search { position: sticky; top: calc(52px + var(--safe-t)); z-index: 5; background: var(--bg); padding: 4px 0 10px; }
.search input { font-size: 18px; padding: 14px 16px; }

.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px; background: var(--bg2);
  border-radius: var(--r); cursor: pointer; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .ar { font-size: 15px; color: var(--muted); direction: rtl; }
.item .meta { font-size: 13px; color: var(--muted); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg3); white-space: nowrap; }
.badge.q { background: var(--qbg); color: var(--q); }
.badge.err { color: var(--err); }
.progress { height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress div { height: 100%; background: var(--teal); transition: width .4s; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; scrollbar-width: none; }
.tabs button { flex: none; }
.song-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.song-head .ar { width: 100%; direction: rtl; color: var(--muted); font-size: 18px; }
.scale { font-size: 14px; color: var(--muted); margin: 6px 0; }
.scale b { color: var(--q); }

.notes { width: 100%; border-collapse: collapse; }
.notes td, .notes th { padding: 10px 6px; border-bottom: 1px solid var(--bg2); text-align: left; }
.notes th { font-size: 12px; color: var(--muted); font-weight: 500; position: sticky; top: calc(52px + var(--safe-t)); background: var(--bg); }
.notes .n { font-size: 20px; font-weight: 700; }
.notes tr.q .n { color: var(--q); }
.notes tr.q { background: var(--qbg); }
.notes tr.now { outline: 2px solid var(--teal); outline-offset: -2px; }
.notes .tm { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.notes .ed { color: var(--teal); font-size: 12px; }
.lowconf { opacity: .55; }

.tab-wrap { overflow-x: auto; }
pre.tab { font: 14px/1.25 ui-monospace, Menlo, Consolas, monospace; margin: 0 0 14px; white-space: pre; }
pre.tab .barno { color: var(--muted); }
pre.tab .qf { color: var(--q); font-weight: 700; }
pre.tab .now { background: rgba(45, 212, 191, .25); }

.chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (min-width: 700px) { .chart { grid-template-columns: repeat(8, 1fr); } }
.bar { background: var(--bg2); border-radius: 8px; padding: 6px 6px 8px; min-height: 64px; cursor: pointer; position: relative; }
.bar .no { position: absolute; top: 2px; right: 6px; font-size: 10px; color: var(--muted); }
.bar .ch { font-size: 19px; font-weight: 700; }
.bar .ch small { font-size: 13px; color: var(--q); }
.bar .bs { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.bar.now { outline: 2px solid var(--teal); }
.legend { font-size: 13px; color: var(--muted); margin: 8px 0; }

#score { background: #fff; border-radius: var(--r); min-height: 200px; overflow-x: auto; }

#player { position: fixed; left: 0; right: 0; bottom: calc(57px + var(--safe-b)); z-index: 19; background: var(--bg2);
  border-top: 1px solid var(--bg3); padding: 6px 10px; }
#player .row { display: flex; align-items: center; gap: 6px; max-width: 980px; margin: 0 auto; }
#player .row.small { margin-top: 4px; }
#player select { width: auto; padding: 6px 8px; font-size: 14px; }
#p-seek { flex: 1; accent-color: var(--gold); }
#p-time, #p-dur { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; }

dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--bg3); border-radius: 16px; padding: 18px; max-width: 420px; width: 92vw; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin: 0 0 8px; }
.grid-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(190px + var(--safe-b)); z-index: 50;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; max-width: 90vw; }

.seg { display: flex; background: var(--bg2); border-radius: var(--r); padding: 4px; gap: 4px; }
.seg button { flex: 1; background: none; border: 0; padding: 10px; border-radius: 9px; color: var(--muted); }
.seg button.on { background: var(--bg3); color: var(--fg); }
.drop { border: 2px dashed var(--bg3); border-radius: var(--r); padding: 28px 12px; text-align: center; color: var(--muted); margin-top: 12px; }
.drop input { display: none; }
.hint { font-size: 13px; color: var(--muted); }

/* repertorio */
.set-item { display: flex; gap: 8px; align-items: center; background: var(--bg2); border-radius: var(--r); padding: 10px; margin-bottom: 6px; }
.set-item .num { width: 28px; text-align: center; font-weight: 700; color: var(--gold); }
.set-item .main { flex: 1; min-width: 0; }
.set-item .mv { display: flex; flex-direction: column; }
.set-item .mv button { padding: 2px 8px; font-size: 18px; }
.set-item.drag { opacity: .5; }

/* modo escenario */
body.stage { padding: 0; }
body.stage #topbar, body.stage #tabbar, body.stage #player { display: none !important; }
.stage-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 14px calc(10px + var(--safe-b)); }
.stage-top { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.stage-top .count { font-size: 18px; font-weight: 700; color: var(--gold); }
.stage-title { font-size: clamp(30px, 7vw, 60px); font-weight: 800; line-height: 1.1; margin: 10px 0 4px; }
.stage-ar { font-size: clamp(22px, 5vw, 40px); direction: rtl; color: var(--muted); }
.stage-info { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; font-size: clamp(16px, 3.5vw, 24px); }
.stage-info span { background: var(--bg2); padding: 6px 12px; border-radius: 10px; }
.stage-chart { flex: 1; overflow-y: auto; }
.stage-chart .chart .ch { font-size: clamp(20px, 4vw, 30px); }
.stage-chart .chart .bs { font-size: clamp(12px, 2.4vw, 17px); }
.stage-note { font-size: clamp(16px, 3vw, 22px); background: var(--qbg); color: var(--q); padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; }
.stage-nav { display: flex; gap: 10px; margin-top: 10px; }
.stage-nav button { flex: 1; font-size: 22px; padding: 18px; border-radius: 14px; border: 0; }
.stage-nav .prev { background: var(--bg3); color: var(--fg); flex: .6; }
.stage-nav .next { background: var(--gold); color: #111; font-weight: 800; }
.stage-next { color: var(--muted); font-size: clamp(15px, 3vw, 20px); margin-top: 8px; text-align: center; }
.beat-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--bg3); display: inline-block; }
.beat-dot.on { background: var(--gold); }

@media print {
  body { background: #fff; padding: 0; }
  #topbar, #tabbar, #player, .tabs, .row-btns, .song-head, .scale, .legend { display: none !important; }
  #score { border-radius: 0; }
}

/* ------------------------------------------------------------------ v2: diseño, login y cuenta */
html, body { background: var(--bg) var(--pattern); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
  "Noto Naskh Arabic", "Geeza Pro", sans-serif; letter-spacing: .1px; }
.ar, .stage-ar, [dir=rtl] { font-family: "Noto Naskh Arabic", "Geeza Pro", "Amiri", serif; }
#topbar { background: rgba(14, 17, 22, .88); border-bottom: 1px solid var(--line); }
#topbar h1 { font-weight: 650; letter-spacing: .3px; }
#band { width: auto; max-width: 45vw; padding: 6px 10px; font-size: 14px; border-radius: 99px; background: var(--bg2); border-color: var(--line); }
#tabbar { background: rgba(23, 27, 34, .96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
#tabbar a.on { color: var(--gold2); }
.btn { background: linear-gradient(180deg, var(--gold2), var(--gold)); box-shadow: 0 2px 10px rgba(201, 164, 92, .25); text-decoration: none; display: inline-block; text-align: center; }
.btn.sec { background: var(--bg3); box-shadow: none; }
.btn.wide { width: 100%; }
.item { border: 1px solid transparent; transition: border-color .2s, transform .15s; }
.item:hover { border-color: var(--line); }
.item:active { transform: scale(.99); }
.item.static { cursor: default; }
.chip.on { background: var(--teal); color: #0b0d10; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
dialog { border: 1px solid var(--line); box-shadow: var(--shadow); }
.hint.err, .err { color: var(--err); }
.center { text-align: center; }
.login .brand { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.login .brand b { display: block; font-size: 22px; letter-spacing: .4px; }
.login .brand span { color: var(--gold); font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; }
.logo { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 34px; color: #0b0d10;
  background: linear-gradient(135deg, var(--gold2), var(--gold)); box-shadow: 0 4px 18px rgba(201, 164, 92, .35); }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 18px; }
.who { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 20px;
  background: var(--bg3); color: var(--gold2); border: 1px solid var(--line); }
.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--gold); margin: 22px 0 10px; font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); margin: 8px 0; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; }
input[type=email] { width: 100%; background: var(--bg2); border: 1px solid var(--bg3); border-radius: var(--r); padding: 12px; }
