/* Musica design system: "ink and paper". Tokens first, then components, then one section per screen.
   See DESIGN.md. Canvases read the same tokens through Musica.color("--name"). */

/* ---------- tokens ---------- */
:root {
  --bg:#f5f2ea; --surface:#fffdf8; --surface-2:#eeeadf; --surface-3:#e6e0d2; --line:#ddd6c6; --line-strong:#c9c0ad;
  --ink:#1e1c19; --ink-2:#5b554b; --ink-3:#8c8577;
  --accent:#b23a26; --accent-hover:#9c3020; --on-accent:#fff; --accent-soft:#f3ddd5; --accent-ink:#8f2c1b;
  --jade:#2c7a69; --jade-soft:#d7eae4; --gold:#a8791f; --gold-soft:#f3e7c9;
  --ok:#2c7a4b; --ok-soft:#dcefe2; --warn:#a8691a; --warn-soft:#f6e8cf; --danger:#b3261e; --danger-soft:#f7dcd9;
  --stage:#fbf9f2; --lane:#f3efe4; --lane-alt:#ebe6d8; --grid:#d9d2c1; --grid-strong:#b9b09c;
  --note:#2c7a69; --note-ink:#fff; --note-active:#b23a26; --note-past:#c4bdac; --playhead:#b23a26;
  --paper:#fffdf8;
  --shadow-1:0 1px 2px rgba(60,45,20,.08);
  --shadow-2:0 10px 30px rgba(60,45,20,.14), 0 2px 6px rgba(60,45,20,.08);
  --r-sm:6px; --r:8px; --r-lg:14px;
  --font:system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  --serif:ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", "Songti SC", Georgia, serif;
  --mono:ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#141517; --surface:#1c1e21; --surface-2:#24272b; --surface-3:#2d3136; --line:#30343a; --line-strong:#454a52;
    --ink:#edebe5; --ink-2:#aaa69c; --ink-3:#7a766d;
    --accent:#e2674b; --accent-hover:#ec7a60; --on-accent:#1a0c08; --accent-soft:#3b231d; --accent-ink:#f0907a;
    --jade:#5cbfa8; --jade-soft:#1d3833; --gold:#e3b558; --gold-soft:#3a3018;
    --ok:#62c088; --ok-soft:#1c3526; --warn:#e0a550; --warn-soft:#3a2e17; --danger:#ef7a70; --danger-soft:#3d1f1c;
    --stage:#101113; --lane:#15171a; --lane-alt:#1a1c20; --grid:#2a2e34; --grid-strong:#444951;
    --note:#4fae98; --note-ink:#0b1513; --note-active:#f08a6c; --note-past:#3a3e44; --playhead:#f08a6c;
    --shadow-1:0 1px 2px rgba(0,0,0,.4);
    --shadow-2:0 12px 32px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:#141517; --surface:#1c1e21; --surface-2:#24272b; --surface-3:#2d3136; --line:#30343a; --line-strong:#454a52;
  --ink:#edebe5; --ink-2:#aaa69c; --ink-3:#7a766d;
  --accent:#e2674b; --accent-hover:#ec7a60; --on-accent:#1a0c08; --accent-soft:#3b231d; --accent-ink:#f0907a;
  --jade:#5cbfa8; --jade-soft:#1d3833; --gold:#e3b558; --gold-soft:#3a3018;
  --ok:#62c088; --ok-soft:#1c3526; --warn:#e0a550; --warn-soft:#3a2e17; --danger:#ef7a70; --danger-soft:#3d1f1c;
  --stage:#101113; --lane:#15171a; --lane-alt:#1a1c20; --grid:#2a2e34; --grid-strong:#444951;
  --note:#4fae98; --note-ink:#0b1513; --note-active:#f08a6c; --note-past:#3a3e44; --playhead:#f08a6c;
  --shadow-1:0 1px 2px rgba(0,0,0,.4);
  --shadow-2:0 12px 32px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing:border-box; }
html, body { height:100%; }
body { margin:0; background:var(--bg); color:var(--ink); font:15px/1.45 var(--font); -webkit-font-smoothing:antialiased; }
[hidden] { display:none !important; }
h1, h2, h3, p { margin:0; }
h1 { font:600 30px/1.15 var(--serif); letter-spacing:-.01em; }
h2 { font:600 20px/1.2 var(--serif); }
a { color:inherit; }
button, input, select, textarea { font:inherit; color:inherit; }
input[type=range], input[type=checkbox], input[type=radio] { accent-color:var(--accent); }
input[type=range] { height:24px; margin:0; cursor:pointer; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
code, pre, .mono { font-family:var(--mono); font-size:13px; }
.hint { color:var(--ink-3); font-size:13px; }
.num-tab { font-variant-numeric:tabular-nums; }
svg.ic { width:18px; height:18px; flex:none; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* ---------- components ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; height:36px; padding:0 14px; white-space:nowrap;
  border:1px solid var(--line-strong); border-radius:var(--r); background:var(--surface); color:var(--ink);
  font-weight:500; text-decoration:none; cursor:pointer; touch-action:manipulation; transition:background .12s, border-color .12s; }
.btn:hover { background:var(--surface-2); }
.btn:active { transform:translateY(1px); }
.btn.primary { background:var(--accent); border-color:transparent; color:var(--on-accent); }
.btn.primary:hover { background:var(--accent-hover); }
.btn.ghost { border-color:transparent; background:transparent; }
.btn.ghost:hover { background:var(--surface-2); }
.btn.sm { height:30px; padding:0 10px; font-size:13px; }
.btn.lg { height:44px; padding:0 22px; font-size:16px; }
.btn:disabled, .icon-btn:disabled { opacity:.4; cursor:default; pointer-events:none; }
.btn[aria-pressed="true"], .icon-btn[aria-pressed="true"] { background:var(--accent-soft); color:var(--accent-ink); border-color:transparent; }
.icon-btn { display:inline-grid; place-items:center; width:36px; height:36px; flex:none; padding:0; border:0; border-radius:var(--r);
  background:transparent; color:var(--ink-2); cursor:pointer; touch-action:manipulation; text-decoration:none; }
.icon-btn:hover { background:var(--surface-2); color:var(--ink); }

.seg { display:inline-flex; gap:2px; padding:3px; border-radius:10px; background:var(--surface-2); }
.seg > * { display:inline-flex; align-items:center; justify-content:center; height:30px; padding:0 14px; border:0; border-radius:7px;
  background:transparent; color:var(--ink-2); font-weight:500; text-decoration:none; white-space:nowrap; cursor:pointer; }
.seg > *:hover { color:var(--ink); }
.seg > .on { background:var(--surface); color:var(--ink); box-shadow:var(--shadow-1); }
.seg.sm > * { height:26px; padding:0 10px; font-size:13px; }

.input { height:36px; padding:0 10px; border:1px solid var(--line-strong); border-radius:var(--r); background:var(--surface); color:var(--ink); min-width:0; }
.input::placeholder { color:var(--ink-3); }
.input:focus { outline:2px solid var(--accent); outline-offset:-1px; border-color:transparent; }
select.input { padding-right:6px; cursor:pointer; }
textarea.input { height:auto; padding:10px 12px; font:13.5px/1.6 var(--mono); resize:vertical; width:100%; display:block; }
.input.num { width:64px; text-align:center; padding:0 4px; font-variant-numeric:tabular-nums; }
.field { display:flex; flex-direction:column; gap:5px; min-width:0; }
.field > span { font-size:12px; font-weight:600; color:var(--ink-2); letter-spacing:.02em; }

.switch { display:inline-flex; align-items:center; gap:9px; cursor:pointer; user-select:none; }
.switch input { appearance:none; -webkit-appearance:none; position:relative; flex:none; width:36px; height:20px; margin:0; border-radius:10px;
  background:var(--line-strong); cursor:pointer; transition:background .15s; }
.switch input::after { content:""; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.3); transition:transform .15s; }
.switch input:checked { background:var(--accent); }
.switch input:checked::after { transform:translateX(16px); }

.chip { display:inline-flex; align-items:center; gap:5px; height:22px; padding:0 9px; border-radius:11px; background:var(--surface-2);
  color:var(--ink-2); font-size:12px; font-weight:500; white-space:nowrap; }
.chip.accent { background:var(--accent-soft); color:var(--accent-ink); }
.chip.jade { background:var(--jade-soft); color:var(--jade); }
.chip.warn { background:var(--warn-soft); color:var(--warn); }
.chip.ok { background:var(--ok-soft); color:var(--ok); }
button.chip { border:0; cursor:pointer; height:30px; padding:0 12px; border-radius:15px; font-size:13px; }
button.chip:hover { background:var(--surface-3); color:var(--ink); }
button.chip.on { background:var(--accent); color:var(--on-accent); }

.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:18px 20px; }
.card > h3, .label { font:600 12px/1.2 var(--font); letter-spacing:.07em; text-transform:uppercase; color:var(--ink-3); }
.card > h3 { margin-bottom:14px; }
.row { display:flex; flex-wrap:wrap; align-items:center; gap:10px; }
.spacer { flex:1; }
.unsaved { display:inline-flex; align-items:center; gap:6px; color:var(--warn); font-size:13px; font-weight:500; }
.unsaved::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--warn); }
.msg { font-size:13px; color:var(--ink-2); min-height:1.3em; }
.msg.err { color:var(--danger); } .msg.ok { color:var(--ok); }
.note { display:flex; gap:10px; align-items:flex-start; padding:10px 12px; border-radius:var(--r); background:var(--surface-2); color:var(--ink-2); font-size:13px; }
.note.warn { background:var(--warn-soft); color:var(--warn); } .note.err { background:var(--danger-soft); color:var(--danger); }
.note.ok { background:var(--ok-soft); color:var(--ok); }
.spin { display:inline-block; width:15px; height:15px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.empty { display:flex; flex-direction:column; align-items:center; gap:10px; padding:48px 20px; text-align:center; color:var(--ink-2); }
.empty h3 { font:600 20px var(--serif); color:var(--ink); }

/* ---------- shell ---------- */
#app { height:100vh; height:100dvh; display:flex; flex-direction:column; }
#topbar { position:relative; z-index:20; flex:none; display:flex; align-items:center; gap:14px; min-height:56px; padding:8px 16px;
  padding-left:max(16px, env(safe-area-inset-left)); padding-right:max(16px, env(safe-area-inset-right));
  background:var(--surface); border-bottom:1px solid var(--line); }
#brand { display:flex; align-items:center; gap:10px; text-decoration:none; font:600 20px var(--serif); letter-spacing:-.01em; }
#songHead { display:flex; align-items:center; gap:6px; min-width:0; flex:1 1 0; }
.song-id { min-width:0; }
#songTitle { font:600 17px/1.2 var(--serif); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#songMeta { font-size:12px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#modeNav { flex:none; }
#modeNav > * { min-width:84px; }
.top-actions { display:flex; align-items:center; gap:4px; margin-left:auto; flex:1 1 0; justify-content:flex-end; }
#brand:not([hidden]) ~ .top-actions { flex:1; }
#busy { position:relative; flex:none; height:2px; margin-top:-2px; z-index:25; overflow:hidden; }
#busy::after { content:""; position:absolute; inset:0; width:40%; background:var(--accent); animation:busy 1.1s ease-in-out infinite; }
@keyframes busy { from { transform:translateX(-100%); } to { transform:translateX(250%); } }
#main { flex:1; min-height:0; overflow:auto; position:relative; }
.view { min-height:100%; }
.page { padding:32px 24px 64px; }
.page > * { max-width:1080px; margin-left:auto; margin-right:auto; }
.page.narrow > * { max-width:760px; }
.page-head { display:flex; flex-wrap:wrap; align-items:flex-end; gap:12px 16px; margin-bottom:24px; }
.page-head .sub { color:var(--ink-3); margin-top:4px; }

#toasts { position:fixed; left:0; right:0; bottom:calc(20px + env(safe-area-inset-bottom)); z-index:60; display:flex; flex-direction:column; align-items:center; gap:8px; pointer-events:none; padding:0 16px; }
.toast { max-width:min(560px, 100%); padding:10px 16px; border-radius:10px; background:var(--ink); color:var(--bg); font-size:14px; box-shadow:var(--shadow-2);
  animation:toast-in .2s ease-out; transition:opacity .3s, transform .3s; }
.toast.has-action { display:flex; align-items:center; gap:6px; padding:6px 8px 6px 16px; pointer-events:auto; }
.toast-act { min-height:34px; padding:0 12px; border:0; border-radius:7px; background:transparent; color:inherit; font:inherit; font-weight:700;
  text-decoration:underline; text-underline-offset:3px; cursor:pointer; touch-action:manipulation; }
.toast-act:hover { background:color-mix(in srgb, currentColor 16%, transparent); }
.menu { position:fixed; z-index:70; min-width:176px; padding:5px; border:1px solid var(--line); border-radius:var(--r);
  background:var(--surface); box-shadow:var(--shadow-2); display:flex; flex-direction:column; animation:toast-in .12s ease-out; }
.menu-item { display:flex; align-items:center; gap:10px; min-height:38px; padding:0 12px; border:0; border-radius:7px; background:transparent;
  color:var(--ink); font:inherit; text-align:left; cursor:pointer; touch-action:manipulation; }
.menu-item:hover, .menu-item:focus-visible { background:var(--surface-2); }
.menu-item.danger { color:var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background:var(--danger-soft); }
.toast.err { background:var(--danger); color:#fff; }
.toast.ok { background:var(--ok); color:#fff; }
:root[data-theme="dark"] .toast.err, :root[data-theme="dark"] .toast.ok { color:#111; }
.toast.out { opacity:0; transform:translateY(6px); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

.drawer { position:fixed; z-index:40; top:56px; right:0; bottom:0; width:min(360px, 100vw); display:flex; flex-direction:column; gap:16px; padding:18px 20px 24px;
  background:var(--surface); border-left:1px solid var(--line); box-shadow:var(--shadow-2); overflow:auto; animation:drawer-in .18s ease-out; }
@keyframes drawer-in { from { transform:translateX(24px); opacity:0; } }
.drawer-head { display:flex; align-items:center; justify-content:space-between; }

/* ---------- library ---------- */
.lib-tools { display:flex; gap:10px; margin-left:auto; align-items:center; }
.search { position:relative; display:flex; align-items:center; }
.search svg { position:absolute; left:10px; color:var(--ink-3); pointer-events:none; }
.search .input { padding-left:34px; width:220px; }
.song-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(250px, 1fr)); gap:16px; }
.song-card { position:relative; border:1px solid var(--line); border-radius:var(--r-lg);
  background:var(--surface); transition:border-color .12s, box-shadow .12s, transform .12s; }
.song-card .card-link { display:flex; flex-direction:column; gap:4px; height:100%; padding:14px 16px 14px; border-radius:inherit;
  color:inherit; text-decoration:none; }
.song-card .card-more { position:absolute; top:20px; right:22px; width:30px; height:30px; border-radius:50%;
  background:color-mix(in srgb, var(--surface) 82%, transparent); color:var(--ink-2); }
.song-card .card-more:hover, .song-card .card-more[aria-expanded="true"] { background:var(--surface); color:var(--ink); box-shadow:var(--shadow-1); }
.song-card:hover { border-color:var(--line-strong); box-shadow:var(--shadow-2); transform:translateY(-1px); }
.song-card .thumb { display:block; width:100%; height:64px; margin-bottom:10px; border-radius:var(--r); background:var(--stage); color:var(--note); }
.song-card .thumb.none { display:grid; place-items:center; color:var(--ink-3); font-size:12px; }
.song-card .t { font:600 18px/1.25 var(--serif); overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.song-card .card-title-input { width:100%; height:34px; margin:-5px 0 -5px; padding:0 8px; font:600 18px/1.25 var(--serif); }
.song-card.renaming, .song-card.renaming:hover { border-color:var(--accent); transform:none; box-shadow:var(--shadow-1); }
.song-card.renaming .card-link { cursor:default; }
.song-card .m { color:var(--ink-2); font-size:13px; }
.song-card .f { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:8px; color:var(--ink-3); font-size:12px; font-variant-numeric:tabular-nums; }

/* ---------- practice ---------- */
#vPractice { height:100%; display:flex; flex-direction:column; }
.practice { flex:1; min-height:0; display:flex; gap:16px; padding:14px 16px 12px; }
.stage-col { flex:1; min-width:0; display:flex; flex-direction:column; gap:10px; }
.stage-head { display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between; gap:8px 16px; }
.now { display:flex; align-items:flex-end; gap:28px; }
.now-item { display:flex; align-items:baseline; gap:8px; white-space:nowrap; }
.now-item .lbl { font:600 11px var(--font); letter-spacing:.08em; text-transform:uppercase; color:var(--ink-3); }
.now-item b { font:600 22px/1 var(--font); font-variant-numeric:tabular-nums; }
.now-item.chord b { font:700 32px/1 var(--font); letter-spacing:-.01em; color:var(--accent); min-width:1.6em; }
.now-item .next { color:var(--ink-3); font-size:14px; font-variant-numeric:tabular-nums; }
.stage-tools { display:flex; align-items:center; gap:8px; }
.stage { position:relative; flex:1; min-height:0; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--stage); overflow:hidden; }
#paneRoll { position:absolute; inset:0; display:flex; flex-direction:column; }
.cv-wrap { position:relative; }
.cv-wrap canvas { position:absolute; inset:0; width:100%; height:100%; display:block; }
.cv-wrap.roll { flex:1; min-height:0; }
.cv-wrap.ribbon { flex:none; height:104px; border-top:1px solid var(--line); }
#paneSheet { position:absolute; inset:0; display:flex; flex-direction:column; background:var(--paper); }
#sheetWrap { position:relative; flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; scrollbar-gutter:stable; cursor:pointer; background:var(--paper); }
#osmd { position:relative; width:100%; max-width:1100px; margin:0 auto; }
#sheetLine { position:absolute; width:3px; border-radius:2px; background:#b23a26; box-shadow:0 0 0 3px rgba(178,58,38,.18); pointer-events:none; display:none; z-index:5; }
#sheetMsg { position:absolute; left:0; right:0; bottom:8px; text-align:center; color:#8c8577; font-size:13px; pointer-events:none; }
#paneJianpu { position:absolute; inset:0; display:flex; flex-direction:column; }
#jpWrap { position:relative; flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; scrollbar-gutter:stable; cursor:pointer; }
#jpSheet { position:relative; z-index:1; width:100%; max-width:1100px; margin:0 auto; }   /* above the line, so digits stay crisp */
#jpSheet svg { display:block; }
#jpSheet text { font-family:var(--font); font-weight:500; font-variant-numeric:tabular-nums; user-select:none; -webkit-user-select:none; }
#jpLine { position:absolute; width:3px; border-radius:2px; background:color-mix(in srgb, var(--playhead) 55%, transparent); box-shadow:0 0 0 3px color-mix(in srgb, var(--playhead) 14%, transparent); pointer-events:none; display:none; z-index:0; }
.jp-sym { color:var(--ink); fill:currentColor; transition:opacity .2s; }
.jp-sym.rest { color:var(--ink-3); }
.jp-sym.past { opacity:.45; }
.jp-sym.on { color:var(--accent); opacity:1; }
#jpSheet .jp-sym.on text { font-weight:700; }
.jp-tie { fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; }
.jp-bar { stroke:var(--ink-2); stroke-width:1.2; fill:none; }
.jp-bar.end { stroke-width:3.2; }
#jpSheet .jp-title { font-family:var(--serif); font-weight:600; fill:var(--ink); }
#jpSheet .jp-meta { fill:var(--ink-2); white-space:pre; }
#jpSheet .jp-chord { fill:var(--accent-ink); font-weight:600; }
#jpSheet .jp-num { fill:var(--ink-3); font-weight:400; }
#countIn { position:absolute; inset:0; z-index:8; display:grid; place-items:center; pointer-events:none;
  font:600 min(42vh, 280px)/1 var(--serif); color:var(--accent); text-shadow:0 0 0 var(--stage), 0 4px 40px var(--stage); font-variant-numeric:tabular-nums; }
#stageEmpty { position:absolute; inset:0; z-index:9; background:var(--stage); justify-content:center; }
#band { flex:none; width:250px; display:flex; flex-direction:column; gap:12px; padding:14px 16px; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); overflow:auto; }
#band h3 { font:600 12px var(--font); letter-spacing:.07em; text-transform:uppercase; color:var(--ink-3); }
#band.off { display:none; }
#mixer { display:flex; flex-direction:column; gap:14px; }
.chan { display:grid; grid-template-columns:1fr auto; gap:2px 6px; align-items:center; }
.chan .nm { display:flex; align-items:center; gap:8px; font-weight:500; min-width:0; }
.chan .dot { width:9px; height:9px; border-radius:50%; flex:none; background:var(--c, var(--jade)); }
.chan .tag { font-size:11px; color:var(--ink-3); font-weight:400; }
.chan input[type=range] { grid-column:1 / -1; width:100%; }
.chan.muted .nm, .chan.muted input[type=range] { opacity:.45; }
.chan .icon-btn { width:32px; height:32px; }

#dock { flex:none; display:flex; flex-wrap:wrap; align-items:center; gap:10px 18px; padding:10px 16px calc(10px + env(safe-area-inset-bottom));
  background:var(--surface); border-top:1px solid var(--line); }
.transport { display:flex; align-items:center; gap:6px; }
.play-btn { display:grid; place-items:center; width:52px; height:52px; border:0; border-radius:50%; background:var(--accent); color:var(--on-accent); cursor:pointer;
  box-shadow:var(--shadow-1); touch-action:manipulation; transition:background .12s, transform .08s; }
.play-btn:hover { background:var(--accent-hover); }
.play-btn:active { transform:scale(.96); }
.play-btn svg.ic { width:26px; height:26px; }
#btnRestart { width:40px; height:40px; }
.scrub { flex:1 1 260px; display:flex; align-items:center; gap:10px; min-width:200px; }
.time { font-size:12px; color:var(--ink-3); font-variant-numeric:tabular-nums; min-width:2.6em; }
#tEnd { text-align:right; }
.track { position:relative; flex:1; height:40px; cursor:pointer; touch-action:none; }
.track .rail { position:absolute; left:0; right:0; top:13px; height:6px; border-radius:3px; background:var(--surface-3); overflow:hidden; }
.track .fill { position:absolute; left:0; top:0; bottom:0; width:0; background:var(--accent); }
.track .loop-region { position:absolute; top:0; bottom:0; background:var(--gold); opacity:.45; }
.track .ticks { position:absolute; left:0; right:0; top:22px; height:18px; pointer-events:none; }
.track .ticks i { position:absolute; top:0; width:1px; height:4px; background:var(--line-strong); }
.track .ticks i.maj { height:6px; background:var(--ink-3); }
.track .ticks span { position:absolute; top:7px; transform:translateX(-50%); font-size:10px; color:var(--ink-3); font-variant-numeric:tabular-nums; }
.track .thumb { position:absolute; top:8px; left:0; width:16px; height:16px; margin-left:-8px; border-radius:50%; background:var(--surface); border:2px solid var(--accent); box-shadow:var(--shadow-1); pointer-events:none; }
.dock-group { display:flex; align-items:center; gap:8px; color:var(--ink-2); }
.dock-group input[type=range] { width:110px; }
.tempo-read { display:flex; flex-direction:column; line-height:1.15; min-width:3.6em; font-variant-numeric:tabular-nums; }
.tempo-read b { font-size:13px; color:var(--ink); }
.tempo-read span { font-size:11px; color:var(--ink-3); }
#dock .btn.sm { height:36px; }
#loopRange { display:inline-flex; align-items:center; gap:4px; }
#loopRange .input.num { width:52px; }
#loopRange .dash { color:var(--ink-3); }

/* ---------- edit (shared) ---------- */
#vEdit { height:100%; display:flex; flex-direction:column; }
.edit-bar { flex:none; display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; padding:12px 16px 0; }
.edit-pane { flex:1; min-height:0; display:flex; flex-direction:column; gap:10px; padding:12px 16px 14px; }
.edit-pane.page { display:block; overflow:auto; padding:24px 16px 48px; }
.toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; padding:8px 10px; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); }
.toolbar .grp { display:flex; align-items:center; gap:2px; }
.toolbar .grp + .grp { padding-left:12px; border-left:1px solid var(--line); }
.toolbar .icon-btn, .toolbar .btn { height:40px; }
.toolbar .icon-btn { width:40px; }
.toolbar .icon-btn svg.ic { width:20px; height:20px; }
.toolbar .icon-btn.on, .toolbar .btn.on { background:var(--accent-soft); color:var(--accent-ink); border-color:transparent; }
.toolbar .end { margin-left:auto; display:flex; align-items:center; gap:12px; }

/* melody editor */
.mel-main { flex:1; min-height:0; overflow:auto; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--stage); }
.mel-scroll { position:relative; overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; }
.mel-scroll canvas { position:sticky; left:0; top:0; display:block; touch-action:pan-x; outline:none; }
.mel-sizer { position:absolute; left:0; top:0; height:1px; pointer-events:none; }

/* chord editor */
.ch-head { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.ch-inspect { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; padding:12px 14px; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); }
.ch-inspect .barno { font:600 16px var(--serif); min-width:3.4em; }
.ch-inspect .input { width:150px; font-weight:600; }
.ch-pal { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.ch-pal button.chip { font-weight:600; min-width:44px; justify-content:center; height:34px; }
.ch-scroll { flex:1; min-height:0; overflow:auto; }
.bar-grid { display:grid; grid-template-columns:repeat(8, minmax(0, 1fr)); gap:8px; }
.bar-cell { display:flex; flex-direction:column; gap:2px; min-height:68px; padding:8px 12px; text-align:left; border:1px solid var(--line); border-radius:var(--r); background:var(--surface); cursor:pointer; }
.bar-cell:hover { border-color:var(--line-strong); }
.bar-cell small { color:var(--ink-3); font-size:11px; font-variant-numeric:tabular-nums; }
.bar-cell b { font:650 19px/1.25 var(--font); }
.bar-cell.sel { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); background:var(--accent-soft); }
#chordText { margin-top:12px; min-height:200px; }

/* history */
.rev { display:flex; flex-direction:column; gap:2px; width:100%; text-align:left; padding:12px 16px; margin-top:8px; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); cursor:pointer; }
.rev:hover { border-color:var(--line-strong); }
.rev.sel { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); cursor:default; }
.rev b { font-weight:600; }
.rev small { color:var(--ink-3); }
.rev .det { display:flex; flex-direction:column; align-items:flex-start; gap:10px; margin-top:10px; padding-top:10px; border-top:1px solid var(--line); color:var(--ink-2); font-size:13px; }

/* ---------- arrange ---------- */
#vArrange { padding-bottom:0; }
#settingsRoot { display:flex; flex-direction:column; gap:16px; }
.arr-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap:16px; align-items:start; }
.arr-col { display:flex; flex-direction:column; gap:16px; min-width:0; }
.inst { display:grid; grid-template-columns:minmax(0, 1fr) minmax(0, 190px); gap:2px 12px; align-items:center; padding:10px 0; border-top:1px solid var(--line); }
.inst:first-of-type { border-top:0; }
.inst .switch { font-weight:500; }
.inst .hint { grid-column:1 / -1; padding-left:45px; }
.inst select:disabled { opacity:.4; }
.inst.off .hint { opacity:.6; }
.stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); gap:12px 20px; padding:14px 16px; margin-top:16px; border-radius:var(--r); background:var(--surface-2); }
.stats .k { color:var(--ink-3); font-size:12px; }
.stats .v { font-weight:500; }
.stats .bad { color:var(--danger); font-weight:600; } .stats .good { color:var(--ok); font-weight:600; }
.fit { margin-top:18px; }
.fit-strip { display:grid; grid-template-columns:repeat(25, minmax(0, 1fr)); gap:2px; margin-top:8px; }
.fit-strip button { position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; height:52px; padding:0; border:0; border-radius:6px;
  background:var(--danger-soft); color:var(--ink-2); font-size:11px; line-height:1.1; cursor:pointer; font-variant-numeric:tabular-nums; overflow:hidden; }
.fit-strip button b { font-size:12px; color:var(--ink); }
.fit-strip button:hover { filter:brightness(.96); }
.fit-strip button.c0 { background:var(--ok-soft); } .fit-strip button.c1 { background:var(--warn-soft); }
.fit-strip button.comfy::after { content:""; position:absolute; top:3px; right:3px; width:5px; height:5px; border-radius:50%; background:var(--jade); }
.fit-strip button.built { box-shadow:inset 0 0 0 1.5px var(--ink-3); }
.fit-strip button.on { box-shadow:inset 0 0 0 2px var(--accent); }
.fit-legend { display:flex; flex-wrap:wrap; gap:6px 14px; margin-top:8px; font-size:12px; color:var(--ink-3); }
.fit-legend i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:5px; vertical-align:-1px; }
.fit-legend i.dot { width:6px; height:6px; border-radius:50%; background:var(--jade); vertical-align:1px; }
.actionbar { position:sticky; bottom:0; z-index:5; display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:12px 0 calc(14px + env(safe-area-inset-bottom)); margin-top:4px;
  background:linear-gradient(transparent, var(--bg) 22%); }
a.btn.off { opacity:.4; pointer-events:none; }

/* ---------- new song ---------- */
.src-grid { display:grid; grid-template-columns:repeat(5, minmax(0, 1fr)); gap:10px; margin-bottom:20px; }
.src { display:flex; flex-direction:column; align-items:flex-start; gap:6px; padding:14px; text-align:left; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); cursor:pointer; }
.src:hover { border-color:var(--line-strong); }
.src.on { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.src .glyph { display:grid; place-items:center; height:36px; min-width:36px; padding:0 8px; border-radius:var(--r); background:var(--surface-2); color:var(--ink-2); font:600 13px var(--mono); letter-spacing:.04em; }
.src.on .glyph { background:var(--accent-soft); color:var(--accent-ink); }
.src .glyph svg.ic { width:20px; height:20px; }
.src b { font-weight:600; }
.src small { color:var(--ink-3); font-size:12px; line-height:1.35; }
.new-panel { display:flex; flex-direction:column; gap:14px; }
.drop { display:flex; flex-direction:column; align-items:center; gap:10px; padding:36px 20px; text-align:center; border:1.5px dashed var(--line-strong); border-radius:var(--r-lg); background:var(--surface); color:var(--ink-2); transition:background .12s, border-color .12s; }
.drop.over { border-color:var(--accent); background:var(--accent-soft); }
.drop > svg.ic { width:30px; height:30px; color:var(--ink-3); }
.drop input[type=file] { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.picked { display:flex; align-items:center; gap:8px; font-weight:500; color:var(--ink); }
.jp-grid { display:grid; grid-template-columns:minmax(0, 3fr) minmax(0, 2fr); gap:14px; align-items:start; }
.jp-grid textarea { min-height:230px; }
.jp-prev { display:flex; flex-direction:column; gap:10px; }
.bar-chips { display:flex; flex-wrap:wrap; gap:4px; }
.bar-chips span { padding:2px 7px; border-radius:5px; font-size:12px; background:var(--ok-soft); color:var(--ok); font-variant-numeric:tabular-nums; }
.bar-chips span.bad { background:var(--danger-soft); color:var(--danger); font-weight:600; }
details.guide { border:1px solid var(--line); border-radius:var(--r); background:var(--surface); }
details.guide summary { padding:10px 14px; cursor:pointer; font-weight:500; }
details.guide table { width:100%; border-collapse:collapse; font-size:13px; }
details.guide td { padding:7px 14px; border-top:1px solid var(--line); vertical-align:top; }
details.guide td:first-child { width:9.5em; font-family:var(--mono); color:var(--accent-ink); white-space:nowrap; }
.new-foot { display:flex; flex-wrap:wrap; align-items:flex-end; gap:14px 18px; margin-top:18px; padding-top:18px; border-top:1px solid var(--line); }
.new-panel + .note, .note + .new-foot { margin-top:14px; }
.new-foot .field { flex:1 1 220px; max-width:320px; }
.new-foot .switch { height:36px; }

/* recorder + tuner */
.rec-top { display:flex; flex-wrap:wrap; align-items:center; gap:18px 24px; }
.rec-btn { display:grid; place-items:center; width:72px; height:72px; flex:none; border:0; border-radius:50%; background:var(--accent); color:var(--on-accent); cursor:pointer; box-shadow:var(--shadow-1); }
.rec-btn:hover { background:var(--accent-hover); }
.rec-btn svg.ic { width:34px; height:34px; }
.rec-btn.live { animation:pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow:0 0 0 12px rgba(178,58,38,.16); } }
.rec-info { display:flex; flex-direction:column; gap:4px; min-width:150px; }
.rec-info .t { font:600 24px/1 var(--font); font-variant-numeric:tabular-nums; }
.rec-live { flex:1 1 200px; display:flex; flex-direction:column; gap:6px; min-width:180px; }
.rec-live .p { font:600 22px/1 var(--serif); min-height:22px; }
.meter { height:6px; border-radius:3px; background:var(--surface-3); overflow:hidden; }
.meter .fill { height:100%; width:0; background:var(--jade); border-radius:3px; }
.rec-opts { display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr)); gap:12px 14px; }
.or { color:var(--ink-3); font-size:13px; }
.tn-note { text-align:center; font:600 96px/1 var(--serif); letter-spacing:-.02em; min-height:96px; }
.tn-note.in { color:var(--ok); }
.tn-note.idle { color:var(--line-strong); font-family:var(--font); font-weight:300; }
.rec-live .p.in { color:var(--ok); }
.gauge .needle.idle { opacity:.25; }
.tn-cents { text-align:center; color:var(--ink-2); min-height:1.4em; font-variant-numeric:tabular-nums; }
.gauge { position:relative; height:34px; margin:2px 6px 0; }
.gauge::before { content:""; position:absolute; left:0; right:0; top:15px; height:4px; border-radius:2px; background:linear-gradient(90deg, var(--danger) 0%, var(--warn) 25%, var(--ok) 44%, var(--ok) 56%, var(--warn) 75%, var(--danger) 100%); opacity:.75; }
.gauge::after { content:""; position:absolute; left:50%; top:6px; width:1px; height:22px; background:var(--ink-3); }
.gauge .needle { position:absolute; top:3px; left:50%; width:4px; height:28px; margin-left:-2px; border-radius:2px; background:var(--ink); transition:left .08s linear; z-index:1; }
.gauge-scale { display:flex; justify-content:space-between; margin:0 6px; font-size:11px; color:var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .practice { flex-direction:column; overflow:auto; }
  .stage-col { min-height:420px; }
  #band { width:auto; flex:none; }
  #mixer { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); }
  .src-grid { grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); }
  .jp-grid { grid-template-columns:1fr; }
  .bar-grid { grid-template-columns:repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  #topbar { flex-wrap:wrap; gap:8px 10px; }
  #modeNav { order:3; width:100%; }
  #modeNav > * { flex:1; }
  #tunerBtn span { display:none; }
  #tunerBtn { padding:0; width:36px; }
  .top-actions { flex:none; }
  .drawer { top:0; }
  .page { padding:20px 16px 56px; }
  h1 { font-size:26px; }
  .lib-tools { margin-left:0; width:100%; }
  .search { flex:1; } .search .input { width:100%; }
  .now { gap:18px; } .now-item.chord b { font-size:28px; }
  .practice { padding:10px 10px 8px; }
  #dock { gap:8px 12px; padding-left:12px; padding-right:12px; }
  .scrub { order:-1; flex-basis:100%; }
  .cv-wrap.ribbon { height:84px; }
  .fit-strip { grid-template-columns:repeat(13, minmax(0, 1fr)); }
  .fit-strip button { font-size:9.5px; } .fit-strip button b { font-size:10px; letter-spacing:-.03em; }
  .toolbar .grp + .grp { padding-left:0; border-left:0; }
  .inst { grid-template-columns:1fr; }
}
/* ---------- sign-in (auth.js) ---------- */
#acct { display:flex; align-items:center; }
#acct:empty { display:none; }
.acct-btn { max-width:220px; gap:8px; }
.acct-email { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; color:var(--ink-2); }
.btn.danger { background:var(--danger); border-color:transparent; color:#fff; }
.btn.danger:hover { background:color-mix(in srgb, var(--danger) 88%, #000); }
:root[data-theme="dark"] .btn.danger { color:#1a0c08; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color:#1a0c08; } }
.menu-note { padding:9px 12px 8px; font-size:12px; color:var(--ink-3); border-bottom:1px solid var(--line); margin-bottom:4px; max-width:280px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.guest-banner { display:flex; align-items:center; gap:12px; margin:-8px auto 20px; padding:10px 14px; border:1px solid var(--line); border-radius:var(--r-lg);
  background:var(--gold-soft); color:var(--ink-2); font-size:14px; }
.guest-banner .ic { flex:none; color:var(--gold); }
.guest-banner .txt { flex:1; min-width:0; }
.modal-back { position:fixed; inset:0; z-index:80; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(20,15,8,.45); animation:toast-in .12s ease-out; }
.modal { width:min(420px, 100%); max-height:100%; overflow:auto; padding:22px 24px 24px; border:1px solid var(--line); border-radius:var(--r-lg);
  background:var(--surface); box-shadow:var(--shadow-2); }
.modal h2 { margin:0 0 14px; font:600 22px/1.2 var(--serif); }
.modal p { margin:0 0 4px; color:var(--ink-2); }
.stack { display:flex; flex-direction:column; gap:14px; }
.stack .btn.lg { width:100%; }
.row.between { justify-content:space-between; flex-wrap:nowrap; }
.form-err { min-height:1.2em; color:var(--danger); font-size:13px; }
.google-slot { display:flex; justify-content:center; min-height:44px; margin-bottom:2px; }
.or-line { display:flex; align-items:center; gap:12px; margin:14px 0 16px; color:var(--ink-3); font-size:12px; text-transform:uppercase; letter-spacing:.06em; }
.or-line::before, .or-line::after { content:""; flex:1; height:1px; background:var(--line); }
.code-input { height:52px; font:600 26px/1 var(--mono, ui-monospace, "SF Mono", Menlo, monospace); letter-spacing:.35em; text-align:center; }
.hint.dev { padding:8px 10px; border-radius:var(--r); background:var(--surface-2); }
@media (max-width: 720px) {
  .acct-email { display:none; }
  .acct-btn { padding:0; width:36px; }
  .guest-banner { margin-top:-4px; flex-wrap:wrap; }
  .modal { padding:18px 18px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; }
}

/* ---------- legal pages (/terms, /privacy, /copyright) and their links ---------- */
.legal-links { display:flex; gap:18px; justify-content:center; margin:40px auto 0; font-size:13px; color:var(--ink-3); }
.legal-links a { color:inherit; text-decoration:none; }
.legal-links a:hover { color:var(--ink); text-decoration:underline; }
.legal-agree { margin-top:2px; text-align:center; }
.legal-agree a { color:var(--accent-ink); }
body.legal-body { height:auto; min-height:100%; }
.legal-top { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; padding:14px 24px; border-bottom:1px solid var(--line); background:var(--surface); }
.legal-brand { font:600 20px/1 var(--serif); text-decoration:none; color:var(--accent); }
.legal-top nav { display:flex; gap:16px; font-size:14px; }
.legal-top nav a { color:var(--ink-2); text-decoration:none; padding:4px 0; border-bottom:2px solid transparent; }
.legal-top nav a:hover { color:var(--ink); }
.legal-top nav a[aria-current="page"] { color:var(--ink); border-bottom-color:var(--accent); }
.legal-page { padding:32px 24px 72px; }
.legal-page article { max-width:720px; margin:0 auto; line-height:1.6; }
.legal-page h1 { margin-bottom:6px; }
.legal-page h2 { margin:28px 0 8px; }
.legal-page p, .legal-page ul, .legal-page ol { margin:0 0 12px; }
.legal-page ul, .legal-page ol { padding-left:22px; }
.legal-page li { margin-bottom:6px; }
.legal-page a { color:var(--accent-ink); }
.legal-page code { font-family:ui-monospace, Menlo, monospace; font-size:.92em; background:var(--surface-2); padding:1px 5px; border-radius:4px; }
.legal-updated { color:var(--ink-3); font-size:13px; margin-bottom:20px; }
.legal-agent { padding:12px 14px; border:1px solid var(--line); border-radius:var(--r); background:var(--surface); white-space:pre-line; }

/* plan limits: the library count, locked Arrange / History / Export cards (light and dark come from the variables) */
.plan-note { color:var(--ink-3); } .plan-full { color:var(--warn); font-weight:600; }
.note.lock-note { align-items:center; margin-bottom:14px; background:var(--gold-soft); color:var(--ink-2); }
.note.lock-note .ic { flex:none; color:var(--gold); }
.locked { opacity:.55; filter:saturate(.6); }
.row.end { justify-content:flex-end; }
.plan-dlg .row { gap:10px; }
@media (max-width: 720px) { .row.end .btn { flex:1; } }
