/* The app's one stylesheet. The player's rules are v1's phone_player.html, unchanged
   except where the CSP forbids style="" in markup: colours and the loop region come in
   as custom properties (el.style.setProperty) and their visibility as classes. */
:root {
  --bg: #0f1216; --panel: #181d23; --raise: #232a33; --line: #2e3742;
  --text: #e8ecf1; --muted: #8f9baa; --accent: #3d8bfd; --on-accent: #fff;
  --mute: #e5534b; --solo: #d4a72c; --loop: #3fb950;
  color-scheme: dark light;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f3f5f7; --panel: #fff; --raise: #e9edf1; --line: #d0d7de;
    --text: #1f2328; --muted: #59636e; --accent: #0969da; --mute: #cf222e; --solo: #b88700; --loop: #1a7f37; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ------------------------------------------------------------------ shell */
.wrap { max-width: 640px; margin: 0 auto; padding: 0 12px calc(32px + env(safe-area-inset-bottom)); }
.page { padding-top: 12px; }
.page h1 { white-space: normal; }
.boot { color: var(--muted); padding: 24px 12px; text-align: center; }
.crumbs { display: flex; gap: 12px; padding-top: 8px; font-size: 14px; }
.crumbs a { line-height: 32px; text-decoration: none; }

/* ------------------------------------------------------------------ player */
.transport { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); }
h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head { display: flex; align-items: center; gap: 6px; }  /* v1 set it twice; the second rule won */
.head h1 { flex: 1; min-width: 0; }
.src { flex: none; font-size: 13px; color: var(--accent); text-decoration: none; padding: 4px 0; }
h2 { font-size: 15px; margin: 20px 0 4px; }
.sub, .hint { color: var(--muted); font-size: 13px; }
.hint { margin: 0 0 6px; }
.status { min-height: 1.35em; }
.subrow { display: flex; align-items: center; gap: 8px; }
.subrow .status { flex: 1; min-width: 0; }
/* a small toggle: outlined and muted when off, in the accent colour when on */
.chip { flex: none; min-height: 26px; min-width: 0; padding: 0 10px; border-radius: 13px; font-size: 13px;
  color: var(--muted); background: transparent; }
.chip[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.status.err { color: var(--mute); }
.clock { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.time { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.time small { font-size: 15px; font-weight: 400; color: var(--muted); }
.where { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.where b { color: var(--text); font-size: 19px; }
/* the lyrics strip: the word being sung sits at the left padding's edge (player/ui.js) */
.lyrics { padding-left: 30%; margin-top: 6px; overflow: hidden; white-space: nowrap; font-size: 22px; line-height: 1.5;
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 88%, transparent); }
.lyr { position: relative; display: inline-block; transform: translateX(var(--lx, 0)); will-change: transform; }
.lyr .sung { color: var(--muted); }
.lyr .on { color: var(--accent); }
.lyr .br { display: inline-block; width: 1.6em; text-align: center; color: var(--muted); }
.lyr .br::before { content: "/"; }
.seek { position: relative; }
.region { position: absolute; top: 50%; height: 12px; margin-top: -6px; border-radius: 6px; background: var(--loop);
  opacity: .18; pointer-events: none; display: none; left: var(--a, 0%); width: var(--w, 0%); }
.region.set { display: block; }
.region.on { opacity: .45; }
input[type=range] { display: block; width: 100%; height: 34px; margin: 0; accent-color: var(--accent);
  touch-action: pan-y; background: transparent; }
.btns { display: flex; gap: 6px; margin-top: 6px; }
.btns > button { flex: 1; }
button { font: inherit; color: var(--text); background: var(--raise); border: 1px solid var(--line); border-radius: 10px;
  min-height: 44px; min-width: 44px; padding: 0 8px; touch-action: manipulation; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button svg { width: 22px; height: 22px; fill: currentColor; vertical-align: middle; }
button.primary { flex: 1.7; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.ab { font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
button[aria-pressed=true].m { background: var(--mute); border-color: var(--mute); color: #fff; }
button[aria-pressed=true].s { background: var(--solo); border-color: var(--solo); color: #111; }
button[aria-pressed=true].lp { background: var(--loop); border-color: var(--loop); color: #fff; }
button[aria-pressed=true].seg, button[aria-pressed=true].oc { background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); }
.track, .extra, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }
.track { border-left: 5px solid var(--c, #8b949e); padding: 6px 10px 4px; }
.nm { flex: 1; min-width: 0; }
.name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.info.err { color: var(--mute); white-space: normal; }
.x { min-width: 36px; padding: 0; color: var(--muted); background: transparent; border-color: transparent; font-size: 18px; }
.ctl { display: grid; grid-template-columns: 30px 1fr 50px; align-items: center; gap: 6px; }
.ctl.pan { grid-template-columns: 30px auto 1fr 50px; }
.ctl.oct { grid-template-columns: 30px auto 1fr; }
.lbl { color: var(--muted); font-size: 12px; }
output { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.segs { display: flex; gap: 4px; }
.segs button { min-width: 38px; min-height: 36px; padding: 0; font-size: 13px; }
.segs .oc { min-width: 48px; }
.extra { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-left: 5px solid var(--c, #8b949e); }
.extra button { min-width: 76px; }
.panel { padding: 8px 10px; }
.meter { display: grid; grid-template-columns: 14px 1fr; gap: 4px 6px; align-items: center; margin: 6px 0 2px; font-size: 11px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--raise); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--loop); }
.bar i.hot { background: var(--mute); }
label.chk { display: flex; align-items: center; gap: 8px; min-height: 40px; }
label.chk input { width: 20px; height: 20px; accent-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.setnav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; padding-top: 4px; }
.setnav a { display: block; min-width: 0; line-height: 40px; color: var(--accent); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setnav a.off { visibility: hidden; }
.setnav .nx { text-align: right; }
.setnav .ls { color: var(--muted); }

/* ------------------------------------------------------------------ screens
   Everything but the player: its rules sit under .page (and .topnav), so the player's
   markup above is untouched. The look is v1's phone_app.html. */
:root { --bad: var(--mute); --good: var(--loop); --warn: var(--solo); }
.topnav { display: flex; gap: 2px; overflow-x: auto; padding-top: 6px; border-bottom: 1px solid var(--line);
  scrollbar-width: none; }
.topnav:empty { display: none; }
.topnav a { flex: none; padding: 0 10px; line-height: 40px; text-decoration: none; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; }
.topnav a[aria-current=page] { color: var(--text); border-bottom-color: var(--accent); }
.topnav .grp { flex: none; align-self: center; max-width: 45%; margin-right: 6px; font: inherit; font-size: 14px;
  font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topnav select.grp { min-height: 32px; padding: 0 4px; background: var(--raise); border: 1px solid var(--line); border-radius: 8px; }
.topnav a.me { margin-left: auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page h1 { font-size: 20px; margin: 4px 0 2px; }
.page h2 { font-size: 15px; margin: 22px 0 6px; }
.page h3 { font-size: 14px; margin: 14px 0 4px; }
.page h3:first-child { margin-top: 0; }
.page .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.page label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.page .form > label:first-child, .page .cols label { margin-top: 0; }
.page label.chk { display: flex; color: var(--text); font-size: 15px; margin: 4px 0; }
.page label.inline { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.page label.inline select { flex: 1; }
.page input:not([type=checkbox]):not([type=range]):not([type=file]), .page select, .page textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; min-height: 44px; padding: 0 10px; }
.page textarea { padding: 8px 10px; min-height: 50vh; font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; overflow-wrap: normal; overflow-x: auto; resize: vertical; tab-size: 4; }
.page input[type=file] { font-size: 14px; max-width: 100%; margin: 4px 0; }
.page input:focus, .page select:focus, .page textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.page input[type=range] { height: 34px; }
.page label output { float: right; }
.page a.btn, .page label.btn { font: inherit; color: var(--text); background: var(--raise); border: 1px solid var(--line); border-radius: 10px;
  min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.page a.btn.primary, .page label.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.page a.btn.off { opacity: .45; pointer-events: none; }
.page label.btn { margin: 0; font-size: 15px; }
.page label.btn.primary { color: var(--on-accent); }
.page button { padding: 0 12px; }
.page button.primary { flex: none; }
.page button.danger, .page button.armed { border-color: var(--bad); color: var(--bad); }
.page button.armed { background: transparent; font-weight: 600; }
.page button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.page .go { width: 100%; margin-top: 14px; }
.page .msg { font-size: 14px; margin: 8px 0 0; overflow-wrap: anywhere; }
.page .msg.err { color: var(--bad); }
.page .msg.ok { color: var(--good); }
.page .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.page .toolbar { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.page .toolbar input { flex: 1; min-width: 0; }
.page .cols { display: flex; gap: 8px; margin-top: 10px; }
.page .cols > * { flex: 1; min-width: 0; }
.page .empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.page .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px;
  margin-left: 4px; white-space: nowrap; }
.page .badge { font-size: 11px; border-radius: 6px; padding: 1px 6px; background: var(--raise); color: var(--muted);
  white-space: nowrap; }
.page .badge.bad { color: var(--bad); }
.page .badge.off { color: var(--good); margin-left: 4px; }
.page a.badge { text-decoration: none; }
.page details { margin-top: 8px; font-size: 14px; }
.page summary { color: var(--muted); cursor: pointer; min-height: 40px; display: flex; align-items: center; }
.page details[open] > summary { color: var(--text); }
.page pre { margin: 4px 0 0; padding: 8px; background: var(--bg); border-radius: 8px; font-size: 11px; line-height: 1.35;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.page code { font-size: 13px; }
.page .list { list-style: none; margin: 0; padding: 0; }
.page .item { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.page .item:last-child { border-bottom: 0; }
.page .item a.grow { text-decoration: none; color: inherit; }
.page .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.page .grow .sub { display: block; }
.page .kv { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }

/* library and song cards */
.page .sh, .page .jh { display: flex; align-items: center; gap: 8px; }
.page .st, .page .jt { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page a.st { color: inherit; text-decoration: none; }
.page .sd { color: var(--muted); font-size: 13px; }
.page .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.page .chip { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px; border-radius: 20px;
  background: var(--raise); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; }
.page .chip .ct { display: flex; flex-direction: column; line-height: 1.2; padding: 4px 0; }
.page .chip small { font-weight: 400; color: var(--muted); font-size: 12px; }
.page a.chip.play { background: var(--accent); border-color: var(--accent); color: var(--on-accent); gap: 8px; padding: 0 14px 0 10px;
  min-height: 48px; }
.page a.chip.play .pi { font-size: 14px; }
.page a.chip.play small { color: var(--on-accent); opacity: .85; }
.page a.chip.play .badge.off { background: rgba(255, 255, 255, .22); color: var(--on-accent); }
.page a.chip.play:active { filter: brightness(.9); }
.page a.gear { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px;
  border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 20px; }
.page a.gear:hover, .page a.gear:focus-visible { color: var(--text); background: var(--raise); }
.page .chip.wait { opacity: .7; }
.page .chip.bad { border-color: var(--bad); }
.page .chip small.new { color: var(--accent); }
.page .addkey { display: flex; gap: 8px; margin-top: 8px; }
.page .addkey select { flex: 1; min-width: 0; }
.page .vers { display: flex; flex-direction: column; gap: 6px; }
.page .ver { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 6px 6px 12px; border-radius: 10px;
  background: var(--raise); border: 1px solid var(--line); }
.page .ver.sel { border-color: var(--accent); }
.page .vk { font-weight: 600; flex: 1; min-width: 8em; }
.page .vk small { font-weight: 400; color: var(--muted); }
.page .vacts { display: flex; flex-wrap: wrap; gap: 6px; }
.page .vacts .btn, .page .vacts button { min-height: 38px; font-size: 14px; padding: 0 10px; }
.page .ver .msg { flex-basis: 100%; }

/* add a song */
.page .keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.page .keys .keybtn:first-child { grid-column: 1 / -1; }
.page .keybtn { min-height: 40px; padding: 0 4px; font-size: 14px; }
.page .results .item { gap: 10px; }
.page .thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; background: var(--raise); }

/* job cards (v1's) */
.page .pill { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.page .pill.running { color: var(--accent); }
.page .pill.done { color: var(--good); }
.page .pill.failed { color: var(--bad); }
.page ol.steps { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; }
.page ol.steps li { padding: 2px 0 2px 22px; position: relative; color: var(--muted); }
.page ol.steps li::before { content: "○"; position: absolute; left: 2px; }
.page ol.steps li.running { color: var(--text); font-weight: 600; }
.page ol.steps li.running::before { content: "●"; color: var(--accent); }
.page ol.steps li.done::before { content: "✓"; color: var(--good); }
.page ol.steps li.skipped { text-decoration: line-through; }
.page ol.steps li.skipped::before { content: "–"; }
.page ol.steps li.failed::before { content: "✕"; color: var(--bad); }
.page ol.steps li.cancelled::before { content: "✕"; }
.page .detail, .page .where-run { font-size: 13px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums; }

/* set lists */
.page .setitems .num { color: var(--muted); min-width: 2em; font-variant-numeric: tabular-nums; }
.page .setitems button { min-width: 40px; padding: 0; }

/* chord editor */
.wrap:has(.page.wide) { max-width: 900px; }
.page .seg-group { display: inline-flex; margin-left: auto; }
.page .seg-group button { border-radius: 0; }
.page .seg-group button:first-child { border-radius: 10px 0 0 10px; }
.page .seg-group button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.page .bars { margin-top: 8px; border-top: 1px solid var(--line); }
.page .barrow { display: flex; align-items: center; gap: 6px; min-height: 46px; border-bottom: 1px solid var(--line); }
.page .barno { width: 2.4em; flex: none; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.page .cchips { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; padding: 3px 0; }
.page .cchip { min-height: 36px; padding: 0 10px; border-radius: 18px; font-weight: 600; }
.page .cchip small { font-weight: 400; color: var(--muted); font-size: 11px; }
.page .cchip.bad { border-color: var(--bad); color: var(--bad); }
.page .cadd { min-width: 36px; min-height: 36px; padding: 0; color: var(--muted); background: transparent; }
.page .cedit { margin: 6px 0; border-color: var(--accent); }
.page .errs { margin: 10px 0 0; padding-left: 0; list-style: none; }
.page .errs li { color: var(--bad); font-size: 14px; }
.page button.linkish { background: none; border: 0; color: var(--bad); min-height: 32px; padding: 0; text-align: left;
  text-decoration: underline; font-size: 14px; }
.page .sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }

/* admin */
.page .gauge { height: 10px; border-radius: 5px; background: var(--raise); overflow: hidden; margin-top: 6px; }
.page .gauge i { display: block; height: 100%; width: var(--w, 0%); background: var(--good); }
.page .gauge.hot i { background: var(--bad); }
.page .linkbox { margin-top: 10px; }
.page .linkbox input { font-size: 13px; }
.page .invite { margin-top: 8px; }

/* chord editor mini player */
.page .cmini { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; gap: 4px; }
.page .cmini-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.page .cmini #mplay { min-width: 84px; }
.page .cmini-time { font-variant-numeric: tabular-nums; font-size: 15px; }
.page .cmini-time small { color: var(--muted); }
.page .cmini-where { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.page .cmini-where strong { color: var(--text); font-size: 17px; margin-left: 4px; }
.page .cmini-where strong.bad { color: var(--bad); }
.page .cmini .seg-group { margin-left: 0; }
.page .cmini .seg-group button[aria-pressed=false] { color: var(--muted); text-decoration: line-through; }
.page .cmini .sub.err { color: var(--bad); }
.page .cchip.now { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.page .cchip.now small { color: var(--on-accent); }
