:root{--bg:#0f1115;--panel:#181b21;--line:#262a33;--fg:#e8e8e8;--dim:#8a93a3;--accent:#ffcc33;--sung:#4fd1ff;--ok:#2f6f4f;--bad:#4a2b2b;--err:#ff6b6b;--ai:#b58cff;
  --safe-t:env(safe-area-inset-top);--safe-b:env(safe-area-inset-bottom);color-scheme:dark}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Noto Sans SC","Segoe UI",Roboto,sans-serif}
body{overscroll-behavior:none}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;background:#232731;border:1px solid #333a46;border-radius:10px;min-height:40px;padding:6px 12px}
button:disabled{opacity:.45;cursor:default}
button.primary{background:var(--accent);color:#111;border-color:var(--accent);font-weight:600}
button.ghost{background:transparent;border-color:transparent}
button.on{background:#2b3a52;border-color:#4fd1ff;color:#fff}
a{color:var(--sung)}
input[type=text],input[type=search],input[type=password],textarea{background:#11141a;border:1px solid #333a46;border-radius:10px;padding:10px 12px;width:100%}
input[type=range]{accent-color:var(--sung)}
.hidden{display:none!important}
.muted{color:var(--dim)}
.err{color:var(--err)}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.grow{flex:1}

/* ---------- top bar */
.top{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:8px;padding:calc(8px + var(--safe-t)) 14px 8px;background:rgba(15,17,21,.92);backdrop-filter:blur(8px);border-bottom:1px solid var(--line)}
.top h1{font-size:18px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top .sub{color:var(--dim);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand{display:flex;align-items:center;gap:8px;font-weight:700;font-size:18px}
.brand i{width:26px;height:26px;border-radius:7px;background:linear-gradient(135deg,#ffcc33,#ff7a59);display:inline-block}

/* ---------- library */
.lib{max-width:860px;margin:0 auto;padding:12px 14px calc(30px + var(--safe-b))}
.hero{color:var(--dim);margin:4px 0 12px;font-size:14px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px;margin:10px 0}
.songs{display:grid;gap:10px;grid-template-columns:minmax(0,1fr)}
.song{display:flex;gap:12px;align-items:center;min-width:0;overflow:hidden;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:12px}
.song .art{width:48px;height:48px;border-radius:10px;flex:none;display:grid;place-items:center;font-weight:700;color:#111;font-size:20px}
.song .info{flex:1;min-width:0}
.song .t{font-weight:600;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.song .m{color:var(--dim);font-size:13px;margin-top:2px;overflow-wrap:anywhere}
.song .acts{display:flex;gap:6px;flex:none}
.song .acts button{min-height:36px;padding:4px 10px;font-size:14px}
.badge{display:inline-block;font-size:11px;padding:1px 6px;border-radius:6px;background:#2a2f3a;color:#bcd;margin-left:6px;vertical-align:1px}
.badge.ai{background:#2e2446;color:#d7c4ff}
.prog{height:6px;background:#2a2f3a;border-radius:3px;overflow:hidden;margin-top:6px}
.prog i{display:block;height:100%;background:var(--sung);transition:width .4s}
.drop{min-width:0;overflow:hidden;border:2px dashed #3a4150;border-radius:14px;padding:16px;text-align:center}
.drop.over{border-color:var(--sung);background:#121a22}
.form{display:grid;gap:10px;margin-top:12px}
details summary{cursor:pointer;color:var(--dim)}

/* ---------- player layout */
.player{position:fixed;inset:0;display:flex;flex-direction:column}
.now{display:flex;gap:12px;align-items:center;padding:6px 14px}
.cur{font-size:40px;font-weight:700;color:var(--accent);min-width:110px;line-height:1.1}
.nxt{font-size:18px;color:#777}
.capo{margin-left:auto;font-size:13px;color:#aab;text-align:right;line-height:1.35}
.capo b{color:var(--fg)}
.sheet{flex:1 1 0;min-height:0;overflow-y:auto;padding:0 14px;-webkit-overflow-scrolling:touch}
.sheet::after{content:"";display:block;height:42vh}
.sec{margin:16px 0 4px;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:#9fb0c8;display:flex;gap:8px;align-items:center}
.sec button{min-height:26px;padding:0 8px;font-size:12px;border-radius:7px}
.sec.ai::before{content:"AI";font-size:10px;background:#2e2446;color:#d7c4ff;border-radius:4px;padding:0 4px}
.line{margin:6px 0 14px;opacity:.5;transition:opacity .2s}
.line.on{opacity:1}
.chars{display:flex;flex-wrap:wrap}
.ch{display:flex;flex-direction:column;align-items:flex-start;min-width:1.15em;cursor:pointer}
.ch b{height:20px;font-size:14px;color:var(--accent);white-space:nowrap;font-weight:600;padding-right:4px}
.ch b.ai{color:#d7c4ff}
.ch i{font-style:normal;font-size:22px;line-height:30px;color:#ddd;white-space:pre}
.ch.sung i{color:var(--sung)}
.inst{color:#778;font-size:14px;margin:10px 0;display:flex;flex-wrap:wrap;gap:6px 14px}
.inst b{color:var(--accent);font-weight:600}
.flag{font-size:12px;color:#d7c4ff;margin:-8px 0 10px}
.edit-mode .ch b{outline:1px dashed #555;border-radius:4px;min-width:16px}
.edit-mode .line{opacity:1}
.edit-mode .line:hover{background:#151922}

footer.ctl{background:var(--panel);padding:8px 12px calc(10px + var(--safe-b));border-top:1px solid var(--line)}
.status{font-size:13px;color:#9ab;margin-bottom:6px;min-height:18px;display:flex;align-items:center;gap:8px}
.status.err{color:var(--err)}
.status .prog{flex:1;margin:0}
.bar{display:flex;align-items:center;gap:10px}
.play{width:56px;height:56px;flex:none;border-radius:50%;border:0;background:var(--accent);color:#111;font-size:22px;padding:0}
.play:disabled{background:#555;color:#888}
.seekwrap{flex:1;position:relative}
.seek{width:100%;height:32px;margin:0}
.loopband{position:absolute;top:12px;height:8px;background:rgba(255,204,51,.35);border-radius:4px;pointer-events:none}
.time{font-size:12px;color:#999;width:84px;text-align:right;font-variant-numeric:tabular-nums}
.mix{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:10px}
.trk{background:#232731;border:1px solid #333;border-radius:10px;padding:6px 6px 4px;text-align:center}
.trk .tb{display:flex;gap:4px}
.trk .tb button{flex:1;min-height:40px;border:0;border-radius:8px;background:var(--ok);color:#fff;font-size:15px;font-weight:600;padding:0 4px}
.trk .tb button.s{flex:0 0 34px;background:#2a2f3a;font-size:12px;font-weight:500}
.trk .tb button.s.on{background:#4fd1ff;color:#111}
.trk.off .tb button:first-child{background:var(--bad);color:#bbb;text-decoration:line-through}
.trk input{width:100%;height:28px;margin:2px 0 0}
.tools{display:flex;gap:8px;margin-top:8px;font-size:14px;align-items:center;flex-wrap:wrap}
.tools .grp{display:flex;align-items:center;gap:4px;background:#1d2128;border-radius:10px;padding:2px 4px}
.tools .grp span{color:var(--dim);font-size:12px;padding:0 4px}
.tools button{min-width:40px;min-height:36px;padding:2px 10px;font-size:15px}
.tools b{min-width:22px;text-align:center}
.dis .trk,.dis .tools button,.dis .seek{opacity:.4;pointer-events:none}
/* phone: the control tray never takes more than ~half the screen; editing hides the mixer */
@media (max-width:899px){footer.ctl{max-height:48vh;overflow-y:auto}}
.editing .mix,.editing .seekwrap,.editing .status{display:none}
.editing footer.ctl .tools:not(.more){display:none}
.editing footer.ctl .more{display:flex}
.more{display:none}
.show-more .more{display:flex}

/* ---------- panels / modals */
.sheetpanel{position:fixed;left:0;right:0;bottom:0;max-height:82vh;overflow:auto;background:#151820;border-top:1px solid var(--line);border-radius:16px 16px 0 0;
  padding:14px 14px calc(16px + var(--safe-b));z-index:20;box-shadow:0 -10px 40px rgba(0,0,0,.5)}
.scrim{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:19}
.sheetpanel h3{margin:0 0 8px;font-size:17px}
.rev{border-top:1px solid var(--line);padding:10px 0;display:flex;gap:10px;align-items:flex-start}
.rev .who{font-size:11px;border-radius:5px;padding:1px 6px;background:#2a2f3a;flex:none;margin-top:2px}
.rev .who.ai{background:#2e2446;color:#d7c4ff}
.rev .what{font-weight:600}
.rev .why{color:#aab;font-size:13px;margin-top:2px}
.rev.reverted .what{text-decoration:line-through;color:#777}
.rev.conflict .what{color:#a77}
.rev button{min-height:32px;font-size:13px;padding:2px 10px;flex:none}
.qr{background:#fff;padding:10px;border-radius:12px;width:max-content;margin:8px auto}
.qr img,.qr svg{display:block;width:220px;height:220px;image-rendering:pixelated}
.linkbox{font-size:13px;word-break:break-all;background:#0c0e12;border-radius:8px;padding:8px 10px;color:#bcd}
.toast{position:fixed;left:50%;bottom:calc(24px + var(--safe-b));transform:translateX(-50%);background:#2b3a52;color:#fff;padding:10px 16px;border-radius:12px;z-index:50;font-size:14px;max-width:90vw}
.aibar{display:flex;gap:8px;align-items:center;font-size:13px;color:#cbbfe8;background:#1b1726;border:1px solid #3a2f55;border-radius:10px;padding:6px 10px;margin:8px 0}
.aibar button{min-height:30px;font-size:13px;padding:2px 10px}
.rhythm{font-family:ui-monospace,Menlo,monospace;letter-spacing:.18em;color:var(--accent)}

/* ---------- stage (TV / projector) */
.stage{position:fixed;inset:0;background:#05060a;display:flex;flex-direction:column;padding:3vh 5vw;overflow:hidden}
.stage .meta{display:flex;justify-content:space-between;color:#7a8394;font-size:2.2vh}
.stage .chords{display:flex;align-items:baseline;gap:4vw;margin-top:3vh}
.stage .c-now{font-size:16vh;font-weight:800;color:var(--accent);line-height:1}
.stage .c-next{font-size:7vh;color:#666}
.stage .c-diag svg{width:14vh;height:auto}
.stage .c-diag{margin-left:auto}
.stage .lyr{flex:1;display:flex;flex-direction:column;justify-content:center;gap:3vh}
.stage .l-now{font-size:9vh;font-weight:700;line-height:1.25}
.stage .l-now .u{color:#e8e8e8}
.stage .l-now .u.sung{color:var(--sung)}
.stage .l-now .u b{display:block;font-size:4.2vh;color:var(--accent);height:5vh;font-weight:700}
.stage .l-now .w{display:inline-block;vertical-align:bottom}
.stage .l-now .u{display:inline-block;white-space:pre}
.stage .l-next{font-size:5vh;color:#59606d}
.stage .sec-now{font-size:2.6vh;color:#9fb0c8;letter-spacing:.1em;text-transform:uppercase}
.stage .pbar{height:.8vh;background:#1a1d24;border-radius:1vh;overflow:hidden}
.stage .pbar i{display:block;height:100%;background:var(--sung)}
.stage .corner{position:absolute;right:3vw;bottom:3vh;display:flex;gap:2vw;align-items:center;color:#556;font-size:2vh}
.stage .corner .qr{padding:1vh}
.stage .corner .qr svg,.stage .corner .qr img{width:14vh;height:14vh}
.stage .tap{position:absolute;inset:0;display:grid;place-items:center;background:rgba(0,0,0,.6);font-size:4vh;z-index:3}
.stage .countdown{position:absolute;inset:0;display:grid;place-items:center;font-size:30vh;font-weight:800;color:var(--accent);pointer-events:none}

/* ---------- remote */
.remote{max-width:520px;margin:0 auto;padding:12px 14px calc(20px + var(--safe-b));display:grid;gap:12px}
.remote .big{display:grid;grid-template-columns:1fr 1.4fr 1fr;gap:10px}
.remote .big button{min-height:72px;font-size:26px;border-radius:16px}
.remote .big .pp{background:var(--accent);color:#111;border:0}
.remote .grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.remote .grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.remote .now-line{font-size:20px;min-height:56px}
.remote .now-chord{font-size:44px;color:var(--accent);font-weight:800}

/* ---------- print */
.print{background:#fff;color:#111;min-height:100%;padding:24px;max-width:900px;margin:0 auto;font-size:15px}
.print h1{margin:0;font-size:26px}
.print .pm{color:#555;margin:4px 0 14px}
.print .diags{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0 18px}
.print .chord-svg .cd-l,.print .chord-svg .cd-nut{stroke:#222}
.print .chord-svg .cd-dot{fill:#111}
.print .chord-svg .cd-open{stroke:#111;fill:none}
.print .chord-svg text{fill:#111}
.print .pl{break-inside:avoid;margin:2px 0 10px}
.print .pl .chars{display:flex;flex-wrap:wrap}
.print .pl .ch b{color:#b3261e;height:18px;font-size:14px}
.print .pl .ch i{color:#111;font-size:17px;line-height:22px}
.print .psec{font-weight:700;margin:16px 0 4px;font-size:13px;text-transform:uppercase;letter-spacing:.06em;color:#333;break-after:avoid}
.print .pinst{color:#555;font-size:14px;margin:6px 0}
.print .pinst b{color:#b3261e}
.print .pfoot{color:#777;font-size:12px;margin-top:24px;border-top:1px solid #ddd;padding-top:8px}
.print .noprint{margin-bottom:14px}
@media print{.noprint{display:none!important} body{background:#fff} .print{padding:0} @page{margin:14mm}}

/* chord diagram (dark default) */
.chord-svg .cd-l{stroke:#8a93a3;stroke-width:1}
.chord-svg .cd-nut{stroke:#ddd;stroke-width:3}
.chord-svg .cd-dot{fill:#ffcc33}
.chord-svg .cd-open{stroke:#ddd;fill:none;stroke-width:1.2}
.chord-svg text{fill:#ddd;font-size:10px;font-family:inherit}
.chord-svg .cd-name{font-size:11px;font-weight:700}
.chord-svg .cd-fr{font-size:8px}
.chord-svg .cd-x{font-size:9px}
.diagrow{display:flex;gap:4px;overflow-x:auto;padding:4px 0 2px}

@media (min-width:900px){
  .player{flex-direction:row}
  .player .main{flex:1;display:flex;flex-direction:column;min-width:0}
  .player footer.ctl{width:380px;border-top:0;border-left:1px solid var(--line);overflow:auto;padding-top:calc(14px + var(--safe-t))}
  .player footer.ctl .more{display:flex}
  .player footer.ctl .moreBtn{display:none}
  .ch i{font-size:26px;line-height:34px}
  .ch b{font-size:16px;height:22px}
  .cur{font-size:52px}
}
@media (max-width:899px){ .player .main{display:contents} }
