/* Chord — mobile-first. Tokens on :root; dark via prefers-color-scheme unless data-theme="light", or forced by data-theme="dark". */
:root {
  --bg: #f5f4f0; --surface: #ffffff; --raised: #faf9f6; --ink: #1b1a17; --muted: #6e6a62; --faint: #a19d94;
  --line: #e7e4dc; --line-strong: #d8d4ca;
  --accent: #3b5bfd; --accent-ink: #ffffff; --accent-soft: #e9edff; --accent-text: #2d48d6;
  --live: #17a35a; --rec: #e5484d; --rec-soft: #fdeceb; --warn: #b7791f;
  --played: #8a867c;
  --key: #ffffff; --key-black: #26241f; --key-on: #3b5bfd;
  --paper: #ffffff;
  --shadow: 0 1px 2px rgba(20, 18, 12, .06), 0 4px 16px rgba(20, 18, 12, .06);
  --shadow-lg: 0 -8px 40px rgba(20, 18, 12, .18);
  --r: 16px; --r-sm: 10px;
  --tab-h: 58px;                 /* the tab bar, without the safe-area inset under it */
  --top-h: 46px;                 /* the top bar, without the safe-area inset above it */
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101012; --surface: #19191c; --raised: #1f1f23; --ink: #f2f1ed; --muted: #9c988f; --faint: #6b6861;
    --line: #2a2a2f; --line-strong: #3a3a40;
    --accent: #7b8cff; --accent-ink: #0d0f1f; --accent-soft: #23284a; --accent-text: #a3b0ff;
    --live: #3ccf7f; --rec: #ff6b6b; --rec-soft: #3a1c1d; --played: #9a958a;
    --key: #e9e7e2; --key-black: #0b0b0c; --key-on: #7b8cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101012; --surface: #19191c; --raised: #1f1f23; --ink: #f2f1ed; --muted: #9c988f; --faint: #6b6861;
  --line: #2a2a2f; --line-strong: #3a3a40;
  --accent: #7b8cff; --accent-ink: #0d0f1f; --accent-soft: #23284a; --accent-text: #a3b0ff;
  --live: #3ccf7f; --rec: #ff6b6b; --rec-soft: #3a1c1d; --played: #9a958a;
  --key: #e9e7e2; --key-black: #0b0b0c; --key-on: #7b8cff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased;
       -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- layout (phone first) ---- */
/* Each view is a fixed scroll container between the top bar and the tab bar, so it keeps its own scroll position. */
.app { min-height: 100%; }
.view { position: fixed; top: calc(var(--top-h) + env(safe-area-inset-top)); left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); overflow-y: auto;
        overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* ---- keyboard (keyboard.js): a phone's on-screen keyboard is up. --kb is how much of the bottom of the window it covers
   (iOS draws it over the page; 0 where the browser makes the window shorter instead), --vvh the height still visible. The tab
   bar and the mini players step aside, and everything pinned to the bottom ends above the keyboard, not behind it. ---- */
html.typing { --tab-h: 0px; }
html.typing .tabbar { display: none; }
html.typing .view, html[data-np].typing .view { bottom: var(--kb, 0px); }        /* no safe-area inset: the keyboard covers it */

/* ---- top bar: the name and, at the right, the button that opens Account and settings (topbar.js) ---- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 35; display: flex; align-items: center; justify-content: space-between; gap: 12px;
          height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px;
          background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(14px);
          -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.topbar .brand { font: 700 18px/1 var(--font-display); letter-spacing: -0.02em; }
.me-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 34px; height: 34px; padding: 0; overflow: hidden;
          border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }
.me-btn:hover { color: var(--ink); border-color: var(--muted); }
.me-btn.text { padding: 0 12px 0 9px; color: var(--ink); }
.me-btn svg.i { width: 18px; height: 18px; }
.me-btn img, .me-btn .me-ini { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.me-btn .me-ini { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font: 700 14px/1 var(--font-display); }
.me-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---- tab bar ---- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: flex; justify-content: center; gap: 4px;
          height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom);
          background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(14px);
          -webkit-backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; max-width: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
                 border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .01em; padding: 0; border-radius: 12px; }
.tabbar button svg.i { width: 23px; height: 23px; stroke-width: 1.8; }
.tabbar button[aria-selected="true"] { color: var(--accent-text); }
.tabbar button[aria-selected="true"] svg.i { stroke-width: 2.2; }
.tabbar button:hover { color: var(--ink); }

/* ---- now playing: the song of a tab that is not open, just above the tab bar (nowplaying.js) ---- */
:root { --np-h: 52px; }
html.typing { --np-h: 0px; }
html[data-np] .view { bottom: calc(var(--tab-h) + var(--np-h) + env(safe-area-inset-bottom)); }
.np-bar { position: fixed; left: 0; right: 0; z-index: 34; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); height: var(--np-h);
          display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; background: var(--surface); border-top: 1px solid var(--line); }
html.typing .np-bar { display: none; }
.np-line { position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: transparent; pointer-events: none; }
.np-line i { display: block; height: 100%; width: 0; background: var(--accent); }
.np-song { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px 8px; border-radius: 10px; text-align: left; }
.np-song:hover { background: var(--raised); }
.np-t { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.np-t b, .np-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-t b { font-size: 14px; }
.np-t small { font-size: 12px; color: var(--muted); }
.np-eq { flex: none; display: inline-flex; align-items: flex-end; justify-content: center; gap: 2px; width: 32px; height: 32px; padding: 8px 0;
         border-radius: 8px; background: var(--accent-soft); }
.np-eq i { width: 3px; height: 4px; background: var(--accent-text); border-radius: 1px; }
.np-eq.on i { animation: np-eq .9s ease-in-out infinite; }
.np-eq.on i:nth-child(2) { animation-delay: -.3s; } .np-eq.on i:nth-child(3) { animation-delay: -.6s; }
@keyframes np-eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }
.np-ctl { flex: none; display: flex; align-items: center; gap: 2px; }
.np-play { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); }
.np-play svg.i { width: 18px; height: 18px; }
@media (max-width: 420px) { .np-ctl [data-np="prev"] { display: none; } }
@media (prefers-reduced-motion: reduce) { .np-eq.on i { animation: none; height: 10px; } }

/* ---- live strip ---- */

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; transition: background .3s; }
.dot.on { background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 20%, transparent); }
.conf { display: block; width: 84px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.conf i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.note-chip { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.rec { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px;
       border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); }
.rec.on { background: var(--rec); border-color: var(--rec); color: #fff; }
.rec.on .rec-dot { background: #fff; animation: pulse 1s ease-in-out infinite; }
.rec:disabled { opacity: .6; cursor: default; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---- canvas ---- */
.canvas { display: flex; flex-direction: column; gap: 14px; padding: 16px; max-width: 880px; margin: 0 auto; }
.empty { padding: 36px 8px 8px; text-align: center; color: var(--muted); }
.empty h1 { margin: 0 0 6px; font: 700 26px/1.2 var(--font-display); letter-spacing: -0.02em; color: var(--ink); }
.empty p { margin: 0 auto 18px; max-width: 34ch; }
.starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.starter { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
        animation: rise .28s ease-out; }
@supports (overflow: clip) { .card { overflow: clip; } }   /* clip, not hidden: hidden makes the card a scroll container, so the score's audio bar (position: sticky) could never stick to the page */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 0 16px; }
.card-kind { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.card-kind svg.i { width: 17px; height: 17px; }
.card-title { flex: 1; min-width: 0; }
.card-title b { display: block; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.card-tools { display: flex; align-items: center; gap: 8px; padding: 10px 16px 0; }
.card-body { padding: 12px 16px 16px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 10px; }
.card .err { color: var(--rec); font-size: 14px; }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: none; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--raised); color: var(--ink); }
.icon-btn.on { color: var(--accent-text); background: var(--accent-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 12px;
       border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg.i { width: 17px; height: 17px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line);
       max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }      /* more choices than a phone is wide (the Songs filter): the row scrolls sideways, it is not cut off */
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; white-space: nowrap; border: 0; background: none; padding: 5px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* chord rows, progressions */
.rows { display: flex; flex-direction: column; gap: 4px; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; border-radius: 12px; }
.row.top { background: var(--accent-soft); }
.row .name { font: 700 22px/1.1 var(--font-display); letter-spacing: -0.02em; min-width: 3.4ch; }
.row .prob { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .bar { flex: 1; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.row .pct { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 3.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.row-detail { padding: 0 6px 6px 12px; }
.prog { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; margin-top: 2px; }
.chip { display: inline-flex; flex-direction: column; align-items: center; min-width: 44px; padding: 5px 9px; border-radius: 10px;
        background: var(--raised); border: 1px solid var(--line); font-weight: 700; font-size: 15px; line-height: 1.15; transition: background .15s, color .15s; }
.chip small { font-weight: 500; font-size: 11px; color: var(--muted); }
.chip.played { color: var(--played); background: transparent; border-style: dashed; }
.chip.now { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.now small { color: inherit; opacity: .8; }
.chip.live { border-color: var(--live); color: var(--live); }
.arrow { color: var(--faint); font-size: 13px; }
.key-line { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.visual { margin-top: 10px; }
.kbs { display: flex; flex-wrap: wrap; gap: 10px; }
.mk { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mkb { width: 132px; height: auto; display: block; }
.mk .wkey { fill: var(--key); stroke: var(--line-strong); stroke-width: .8; }
.mk .bkey { fill: var(--key-black); }
.mk .on { fill: var(--key-on); }
.mk figcaption { font-size: 13px; font-weight: 700; display: flex; gap: 5px; align-items: baseline; }
.mk figcaption small { font-weight: 500; color: var(--muted); }
.nokb { display: grid; place-items: center; width: 132px; height: 56px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 12px; }
.paper { background: var(--paper); color: #000; border-radius: 10px; padding: 4px 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.paper:empty { padding: 0; }
.paper svg { display: block; margin: 0; }
.osheet { min-height: 40px; }

.section { padding: 10px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.section-head b { text-transform: capitalize; font-size: 14px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar4 { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); transition: border-color .15s; }
.bar4.now { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bar4 .bc b { display: block; font-size: 16px; }
.bar4 .bc small { color: var(--muted); font-size: 12px; }
.mnotes { display: flex; flex-wrap: wrap; gap: 5px; }
.mnotes span { padding: 3px 7px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.mnotes span small { color: var(--muted); font-weight: 500; margin-left: 3px; }
.mnotes span.rest { color: var(--faint); font-weight: 500; }

.score-audio { display: block; width: 100%; height: 40px; margin: 0 0 6px; position: sticky; top: calc(var(--live-h, 64px) + 6px); z-index: 3; }   /* stays visible while you scroll down the score */
.mix-ctl { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }   /* recording ⟷ piano crossfade (music/midimix.js) */
.mix-ctl input[type="range"] { flex: 1; min-width: 80px; max-width: 260px; accent-color: var(--accent); }
.lp-ctl.mix-ctl { margin: 0; }
.lp-ctl.mix-ctl input[type="range"] { width: 110px; flex: none; }
.score-info { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.score-info b { color: var(--ink); }
/* Standard / Guitar / Tab above a score (music/scoreview.js) */
.score-view { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; }
.score-view .score-view-note { margin: 0; font-size: 12px; flex: 1 1 220px; color: var(--muted); }
details.adjust { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.adjust summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent-text); padding: 6px 0; list-style: none; }
details.adjust summary::-webkit-details-marker { display: none; }

.track audio { width: 100%; margin-top: 4px; }
.stem { margin-top: 10px; }
.stem:first-child { margin-top: 0; }
.stem-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stem-acts { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.stem audio { display: block; width: 100%; margin-top: 4px; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 12px 0 6px; }
.progress i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 6px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.note-body { white-space: pre-wrap; }

/* ---------------------------------------------------------------- forms ---- */
.form { display: flex; flex-direction: column; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span, .fld > label { font-size: 13px; font-weight: 600; color: var(--muted); }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong);
       background: var(--surface); font-size: 16px; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.fld .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.src-add { display: flex; gap: 8px; align-items: center; }
.src-add input { flex: 1; min-width: 0; }
.src-add .btn { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 4px 0; }
.toggle span { font-size: 15px; }
.toggle span small { display: block; color: var(--muted); font-size: 12px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 46px; height: 28px; border-radius: 28px; background: var(--line-strong); margin: 0; transition: background .15s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.form-note { font-size: 13px; color: var(--muted); margin: 0; }
.form-actions { display: flex; gap: 10px; }
.form-actions .btn { flex: 1; min-height: 48px; font-size: 15px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list button.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 8px 14px;
       border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; }
.list .item small { color: var(--muted); font-size: 12px; }
.hist-edit { display: flex; flex-wrap: wrap; gap: 8px; }
.hist-edit .chip { flex-direction: row; gap: 6px; padding-right: 4px; }
.hist-edit .chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 7px; background: none; color: var(--muted); padding: 0; }
.hist-edit .chip button:hover { background: var(--rec-soft); color: var(--rec); }

/* ---------------------------------------------------------------- tools sheet ---- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 10, 12, .38); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: min(88vh, 760px); display: flex; flex-direction: column;
         background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); padding-bottom: env(safe-area-inset-bottom);
         animation: up .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(100%); } }
.sheet-grip { width: 38px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 12px; }
.sheet-head h2 { flex: 1; margin: 0 0 0 6px; font: 700 18px/1.2 var(--font-display); }
.sheet-body { overflow-y: auto; padding: 8px 16px 20px; -webkit-overflow-scrolling: touch; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 92px; padding: 14px; border-radius: 16px; border: 1px solid var(--line);
        background: var(--raised); text-align: left; }
.tile .card-kind { width: 34px; height: 34px; }
.tile b { font-size: 15px; }
.tile small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.ctx-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: 14px;
            background: var(--accent-soft); color: var(--accent-text); font-size: 14px; border: 0; width: 100%; text-align: left; }
.ctx-line b { color: var(--ink); }

/* ---------------------------------------------------------------- agent ---- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.12); opacity: .35; } }

/* Hover help (tip.js): one bubble on <body>, placed under or above what is hovered */
.hovertip { position: fixed; z-index: 90; max-width: min(300px, calc(100vw - 12px)); padding: 7px 10px; border-radius: 9px; background: var(--ink); color: var(--bg);
  font: 500 12.5px/1.4 var(--font); box-shadow: 0 6px 20px rgba(0, 0, 0, .22); pointer-events: none; white-space: normal; overflow-wrap: anywhere; }
.hovertip[hidden] { display: none; }
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 60; transform: translateX(-50%); max-width: calc(100% - 32px);
         padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); animation: rise .2s; }

/* ---------------------------------------------------------------- desktop ---- */
@media (min-width: 960px) {
  .only-phone { display: none !important; }
  .tabbar { gap: 8px; }
  .tabbar button { flex-direction: row; gap: 8px; font-size: 13px; max-width: 150px; }
  .tabbar button svg.i { width: 20px; height: 20px; }
  .canvas { padding: 24px 28px; gap: 16px; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: min(560px, calc(100vw - 48px)); transform: translate(-50%, 50%); border-radius: 22px; max-height: 84vh; animation: fade .2s; }
  .sheet-grip { display: none; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .live, .live-more, .dock, .agent, .peek, .card-actions, .card-foot, details.adjust, .empty, .tabbar, .topbar { display: none !important; }
  body { background: #fff; } .app, .view.chat { display: block; height: auto; }
  .view { position: static; overflow: visible; }
  .card { box-shadow: none; border: 0; break-inside: avoid; } .canvas { max-width: none; padding: 0; }
}

/* ---------------------------------------------------------------- prompt optimizer (Make music / Remix / Edit) ---- */
.opt { gap: 8px; }
.opt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-head .hint { flex: 1 1 200px; min-width: 0; }
#g-opt-box { display: flex; flex-direction: column; gap: 6px; }
#g-opt-box[hidden] { display: none; }
#g-opt-box > label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------------------------------------------------------------- pages (Account and settings) ---- */
.page { max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.me-head { display: flex; align-items: center; gap: 6px; margin-left: -8px; }
.me-head h1 { flex: 1; min-width: 0; margin: 0; font: 700 28px/1.15 var(--font-display); letter-spacing: -0.02em; }
.me-head .seg button { padding: 6px 14px; font-size: 13px; }
.page-lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.set-group { margin-top: 22px; }
.set-group h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.set-group h2 svg.i { width: 16px; height: 16px; }
.set-card { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 44px; }
.set-label { flex: 1 1 180px; min-width: 0; }
.set-label b { display: block; font-size: 15px; font-weight: 500; }
.set-label small { display: block; font-size: 12px; color: var(--muted); }
.set-ctl { flex: none; max-width: 100%; }
.set-ctl select { min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; }
.set-card .toggle { padding: 0; }
.range { display: inline-flex; align-items: center; gap: 8px; }
.range input { width: 140px; accent-color: var(--accent); }
.range output { min-width: 3ch; font-variant-numeric: tabular-nums; font-weight: 600; }
.svc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.svc-list li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.svc-list .svc { grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
.svc-list .svc svg.i { width: 16px; height: 16px; }
.svc.on { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.svc.off { background: var(--rec-soft); color: var(--rec); }
.svc-list b { font-size: 14px; }
.svc-list small { font-size: 12px; color: var(--muted); }

/* the generic dialog (dialog.js) on top of the tab bar */
.sheet.dlg .sheet-head h2 { margin-left: 8px; }
@media (min-width: 960px) { .sheet.dlg.wide { width: min(760px, calc(100vw - 48px)); } }
/* a full-screen dialog (sheet music): the whole window, the score scrolls under the head; the player bar sticks to the bottom of the body */
.sheet.dlg.full, .sheet.dlg.full.wide { inset: 0; width: auto; height: 100vh; height: 100dvh; max-height: none; transform: none; border-radius: 0; animation: fade .2s;
  padding-bottom: 0; }
.sheet.dlg.full .sheet-grip { display: none; }
.sheet.dlg.full .sheet-head { padding: calc(6px + env(safe-area-inset-top)) 12px 6px; border-bottom: 1px solid var(--line); }
.sheet.dlg.full .sheet-body { flex: 1; min-height: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.sheet.dlg.full .sheet-body > * { max-width: 1400px; margin-left: auto; margin-right: auto; }
/* keyboard up: a sheet sits on the keyboard and is no taller than what is left; its body scrolls (keyboard.js) */
html.typing .sheet { bottom: var(--kb, 0px); max-height: calc(var(--vvh, 100vh) - 8px); padding-bottom: 0; }
@media (min-width: 960px) { html.typing .sheet { bottom: calc(50% + var(--kb, 0px) / 2); max-height: calc(var(--vvh, 100vh) - 24px); } }
html.typing .sheet.dlg.full, html.typing .sheet.dlg.full.wide { top: 0; bottom: var(--kb, 0px); height: auto; max-height: none; }
html.typing .sheet.dlg.full .sheet-body { padding-bottom: 12px; }
html.typing .sheet .sheet-grip { display: none; }                                  /* every row counts above a keyboard */
/* Touch devices: things to tap are at least 32 to 36 px in their short direction (a finger, not a mouse pointer). The look
   stays; the box that takes the tap grows. */
@media (pointer: coarse) {
  .seg button { min-height: 34px; }
  input[type="range"] { min-height: 32px; }
  input[type="checkbox"]:not(.switch), input[type="radio"] { width: 20px; height: 20px; }
  .btn.small { min-height: 36px; }
  .acct-link { padding: 8px 0; }
}
/* Text fields are 16px on touch devices: iOS Safari zooms the whole page into any field with smaller type, and does not zoom back out */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]), textarea, select { font-size: 16px !important; }
}

/* ---------------------------------------------------------------- the score player (music/scoreplayer.js) ---- */
/* One bar under every drawn score, sticky at the bottom of its scroll container (the tab, or a dialog's body); in Chat on a phone it
   sits above the composer dock. The panel (Edit / Ask) opens above the controls, inside the bar. */
.sp-paper { cursor: pointer; user-select: none; -webkit-user-select: none; }
.sp-paper.sp-selecting, .sp-paper.sp-selecting * { touch-action: none; }
.sp-paper.sp-hearing { cursor: crosshair; }
.sp-paper.sp-hearing, .sp-paper.sp-hearing * { touch-action: none; }            /* a drag sounds notes: it must not scroll the page */
.sp-scrub { position: absolute; width: 3px; border-radius: 2px; background: var(--accent); opacity: .75; pointer-events: none; z-index: 1; }
/* The keyboard above a score (music/scoreplayer.js): lights the notes sounding now, right hand blue, left hand orange. */
.sp-kb { position: sticky; top: var(--sp-kb-top, 0px); z-index: 4; display: flex; align-items: center; gap: 12px; margin: 0 0 8px; padding: 6px 10px; border-radius: 12px;
         border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.sp-kb[hidden] { display: none; }
.sp-kbsvg { flex: 1; min-width: 0; width: 100%; height: auto; max-height: 128px; display: block; }
.sp-kbnames { flex: none; width: 9.5em; min-height: 1.3em; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent-text); overflow-wrap: anywhere; }
.sp-kb .wkey { fill: var(--key); stroke: var(--line-strong); stroke-width: 1; }
.sp-kb .bkey { fill: var(--key-black); }
.sp-kb .klabel { font-size: 9px; fill: var(--muted); pointer-events: none; }
.sp-kb .wkey.rh { fill: color-mix(in srgb, var(--accent) 78%, var(--key)); }
.sp-kb .bkey.rh { fill: var(--accent); }
.sp-kb .wkey.lh { fill: color-mix(in srgb, #f08a24 80%, var(--key)); }
.sp-kb .bkey.lh { fill: #f08a24; }
@media (max-width: 560px) { .sp-kbnames { display: none; } }
.sp-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.sp-layer i { position: absolute; border-radius: 6px; background: rgba(59, 91, 253, .14); box-shadow: inset 0 0 0 1.5px rgba(59, 91, 253, .55); }
.sp-layer b.g { position: absolute; width: 6px; height: 28px; margin: -14px 0 0 -3px; border-radius: 3px; background: rgb(59, 91, 253); box-shadow: 0 0 0 2px var(--surface, #fff); }
.sp-paper.sp-resizable { cursor: ew-resize; }
.sp-bar { position: sticky; bottom: 8px; z-index: 6; margin: 10px 0 0; padding: 8px 10px 8px; border-radius: 16px; border: 1px solid var(--line);
          background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
          box-shadow: 0 -2px 4px rgba(20, 18, 12, .04), 0 -8px 28px rgba(20, 18, 12, .10); color: var(--ink); }      /* the dock is a little taller than --dock-h (its talk button) */
@media (max-width: 560px) { .sp-hint { display: none; } .sp-sel:not(:has(.sp-chip)) { display: none; } .sp-speed input { width: 80px; } }
.sp-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
/* minimize: a tab on the bar's top edge folds it down to a small play / time pill (the tab stays, to open it again) */
.sp-minbtn { position: absolute; top: -22px; right: 14px; width: 40px; height: 22px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-bottom: 0;
             border-radius: 11px 11px 0 0; background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--muted); cursor: pointer; }
.sp-minbtn svg.i { width: 16px; height: 16px; transition: transform .2s; }
.sp-min .sp-minbtn svg.i { transform: rotate(180deg); }
.sp-min { width: fit-content; max-width: 100%; margin-left: auto; padding: 6px 12px 6px 8px; }
.sp-min .sp-more, .sp-min .sp-panel, .sp-min .sp-seek, .sp-min [data-sp="start"] { display: none !important; }
.sp-min:has(.sp-main[hidden]) { padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; height: 0; margin-top: 0; }   /* nothing but the tab */
.sp-main { flex-wrap: nowrap; }
.sp-more { margin-top: 4px; }
.sp-play { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none; background: var(--accent); color: var(--accent-ink);
           box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 40%, transparent); }
.sp-play svg.i { width: 20px; height: 20px; }
.sp-main .icon-btn { width: 34px; height: 34px; }
.sp-time { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 82px; }
.sp-time b { color: var(--ink); font-weight: 600; }
.sp-seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
.sp-speed, .sp-loop { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sp-speed input { width: 96px; accent-color: var(--accent); }
.sp-speed output { min-width: 36px; font-variant-numeric: tabular-nums; color: var(--ink); }
.sp-loop { cursor: pointer; }
.sp-loop input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.sp-loop span { display: inline-flex; align-items: center; gap: 4px; }
.sp-loop svg.i { width: 15px; height: 15px; }
.sp-mixslot:empty { display: none; }
.sp-mixslot .mix-ctl { margin: 0; }
.sp-mixslot .mix-ctl input[type="range"] { width: 100px; min-width: 70px; flex: none; }
.sp-sel { flex: 1 1 140px; min-width: 0; }
.sp-hint { color: var(--faint); font-size: 12px; }
.sp-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; }
.sp-chip b { font-weight: 700; white-space: nowrap; }
.sp-chip small { color: var(--accent-text); opacity: .8; white-space: nowrap; }
.sp-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: inherit; padding: 0; }
.sp-chip button svg.i { width: 14px; height: 14px; }
.sp-acts { display: inline-flex; gap: 6px; margin-left: auto; }
.sp-acts .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.sp-panel { max-height: min(52vh, 460px); overflow-y: auto; margin: -2px -4px 8px; padding: 4px 4px 10px; border-bottom: 1px solid var(--line); }
.sp-ph { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.sp-ph > div:first-child { flex: 1; min-width: 0; }
.sp-ph b { display: block; font-size: 15px; }
.sp-ph small { display: block; color: var(--muted); font-size: 12px; }
.sp-ph .icon-btn { width: 32px; height: 32px; margin: -4px -4px 0 0; }
.sp-seg { flex: none; }
.sp-panel textarea, .sp-askf input { width: 100%; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; resize: vertical; }
.sp-panel textarea:focus, .sp-askf input:focus { outline: none; border-color: var(--accent); }
.sp-ideas { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sp-idea { border: 1px solid var(--line-strong); background: var(--raised); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink); }
.sp-idea:hover { border-color: var(--accent); color: var(--accent-text); }
.sp-frow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 8px 0 0; }
.sp-fld { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sp-fld select { min-height: 32px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; color: var(--ink); }
.sp-check { display: inline-flex; align-items: flex-start; gap: 6px; font-size: 12px; color: var(--muted); max-width: 46ch; }
.sp-check input { accent-color: var(--accent); margin: 2px 0 0; }
.sp-note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.sp-warn { color: var(--warn); font-size: 13px; margin: 8px 0 0; }
.sp-cost { min-height: 3em; }        /* the cost arrives a moment later; reserving its lines keeps the panel (which grows upward) from jumping under the pointer */
.sp-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.sp-res { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); }
.sp-res b { flex: 1; min-width: 90px; font-size: 14px; }
.sp-chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sp-q { align-self: flex-end; max-width: 88%; padding: 7px 12px; border-radius: 14px 14px 4px 14px; background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.sp-q small { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.sp-a { align-self: flex-start; max-width: 96%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--raised); border: 1px solid var(--line); font-size: 14px; line-height: 1.45; }
.sp-a.err { color: var(--rec); }
.sp-a.pending { width: 160px; }
.sp-a.pending .progress { margin: 4px 0; }
.sp-askf { display: flex; gap: 8px; align-items: center; }
.sp-askf input { flex: 1; min-width: 0; }
@media print { .sp-bar { display: none !important; } }

/* the MIDI view of a score (js/music/midiroll.js): the staff is collapsed (it keeps its width and cursor), a piano roll sits after it */
.paper.paper-hidden { visibility: hidden; height: 0; padding: 0; margin: 0; overflow: hidden; }
.midi-roll { padding: 4px 0; overflow: hidden; }
.midi-roll-body { display: flex; align-items: flex-start; }
.midi-axis { flex: none; display: block; }
.midi-scroll { position: relative; flex: 1 1 auto; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.midi-scroll canvas { display: block; }
.midi-head { position: absolute; left: 0; top: 0; width: 2px; margin-left: -1px; background: #e11d48; pointer-events: none; }
.sv-chords { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.sv-chords input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* Quick output picker (output.js): opens above the player's headphones button */
.out-pop { position: fixed; z-index: 60; width: min(300px, calc(100vw - 16px)); max-height: min(60vh, 420px); overflow-y: auto; padding: 6px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg, var(--shadow)); }
.out-pop h4 { margin: 6px 10px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.out-pop button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: 14px; text-align: left; }
.out-pop button:hover, .out-pop button:focus-visible { background: var(--raised); }
.out-pop button[aria-checked="true"] { color: var(--accent-text); font-weight: 600; }
.out-pop .out-ck { display: grid; place-items: center; width: 18px; flex: none; }
.out-pop .out-ck svg.i { width: 16px; height: 16px; }
.out-pop .out-more { color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 9px 9px; margin-top: 4px; }
.out-pop p { margin: 6px 10px; font-size: 12px; color: var(--muted); }
.cr-pl-vol .out-btn { width: 34px; height: 34px; }
.cr-pl-vol .out-btn svg.i { width: 18px; height: 18px; }
