/* Studio */
.studio { height: 100vh; min-height: 560px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; overflow: hidden; }
.studio.view-enter { animation: none; }
.studio > * { min-width: 0; }

/* ---------- top bar ---------- */
.s-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 20px; height: 68px; padding: 0 18px 0 12px;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(17,20,27,.9), rgba(11,13,18,.85)); backdrop-filter: blur(10px); position: relative; z-index: 5; }
.s-top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.s-mark svg.mark { width: 34px; height: 34px; display: block; filter: drop-shadow(0 4px 10px rgba(227,196,140,.15)); }
.s-heading { min-width: 0; padding-left: 4px; }
.s-title { font: 450 21px/1.15 var(--f-display); font-variation-settings: "opsz" 60; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.s-meta .badge { height: 18px; font-size: 9.5px; padding: 0 7px; }
.meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-4); flex: none; }
.s-top-center { display: flex; align-items: center; gap: 12px; }
.s-top-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.btn .chev { width: 14px; height: 14px; margin-right: -4px; opacity: .6; transition: transform .2s var(--ease); }
.btn.open .chev { transform: rotate(180deg); }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 290px; padding: 6px; border-radius: 16px; z-index: 40;
  background: rgba(23,27,36,.97); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); backdrop-filter: blur(16px);
  transform-origin: top right; animation: menu-in .22s var(--ease-spring) both; }
.menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.menu-item { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; width: 100%; padding: 9px 10px; border: 0; border-radius: 11px; background: none; cursor: pointer; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: rgba(255,255,255,.05); outline: none; }
.mi-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(227,196,140,.08); color: var(--brass); }
.mi-ico svg { width: 18px; height: 18px; }
.mi-text b { display: block; font-weight: 600; font-size: 13.5px; }
.mi-text small { color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------- body ---------- */
.s-body { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 0; }
.s-side { overflow-y: auto; padding: 16px 16px 24px; border-right: 1px solid var(--line); background: rgba(6,7,10,.35); scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 24px), transparent); }
.side-sec { padding: 6px 4px 18px; }
.side-sec + .side-sec { border-top: 1px solid var(--line); padding-top: 16px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.side-head h2 { font: 600 11px/1 var(--f-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--text-3); }
.side-count, .side-hint { font-size: 11.5px; color: var(--text-4); }
.side-note { font-size: 12px; line-height: 1.5; color: var(--text-3); margin-top: 9px; }
.demo-note { display: grid; grid-template-columns: 14px 1fr; gap: 8px; padding: 9px 10px; border-radius: 10px; background: rgba(227,196,140,.05); border: 1px solid rgba(227,196,140,.12); }
.demo-note svg { width: 14px; height: 14px; color: var(--brass); margin-top: 1px; }

.parts-list { display: grid; gap: 3px; margin: 0 -6px; }
.part-row { position: relative; display: grid; grid-template-columns: 18px 30px minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: auto; gap: 10px; align-items: center; padding: 8px 8px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.part-row.original { grid-template-columns: 30px minmax(0, 1fr); cursor: default; margin-bottom: 4px; padding-bottom: 11px; border-bottom: 1px dashed var(--line); border-radius: 12px 12px 0 0; }
.part-row:hover:not(.disabled):not(.original) { background: rgba(255,255,255,.035); }
.part-row:focus-within:not(.original) { background: rgba(255,255,255,.035); }
.cbx { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-3); display: grid; place-items: center; color: transparent; transition: all .18s var(--ease); background: var(--ink-0); }
.cbx svg { width: 12px; height: 12px; stroke-width: 3; transform: scale(.5); transition: transform .2s var(--ease-spring); }
.part-row.on .cbx { background: var(--brass); border-color: var(--brass); color: #1d160b; }
.part-row.on .cbx svg { transform: none; }
.part-row input:focus-visible + .cbx { outline: 2px solid var(--brass); outline-offset: 2px; }
.part-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.045); color: var(--text-2); border: 1px solid var(--line); }
.part-ico svg { width: 16px; height: 16px; }
.part-row.kind-vocals .part-ico { color: var(--rh); background: rgba(255,145,112,.08); border-color: rgba(255,145,112,.18); }
.part-row.kind-bass .part-ico { color: var(--lh); background: rgba(95,211,198,.08); border-color: rgba(95,211,198,.18); }
.part-row.kind-piano .part-ico, .part-row.original .part-ico { color: var(--brass); background: rgba(227,196,140,.08); border-color: rgba(227,196,140,.18); }
.part-text { min-width: 0; display: grid; }
.part-text b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-text small { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-row:not(.on):not(.original) .part-text b { color: var(--text-2); }
.part-row.disabled { cursor: not-allowed; }
.part-row.disabled .cbx { border-style: dashed; opacity: .5; }
.part-row.disabled .part-ico, .part-row.disabled .part-text { opacity: .5; }
.mel-tag { font: 600 9.5px/1 var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--rh); padding: 4px 6px; border-radius: 6px; background: rgba(255,145,112,.1); border: 1px solid rgba(255,145,112,.2); }
.preview-btn { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-2); background: var(--ink-2); color: var(--text-2); cursor: pointer; transition: all .18s var(--ease); padding: 0; }
.preview-btn:hover { color: var(--text); border-color: var(--line-3); transform: scale(1.06); }
.preview-btn .i-play { width: 11px; height: 11px; margin-left: 1px; }
.preview-btn .eq { display: none; gap: 2px; align-items: flex-end; height: 11px; }
.preview-btn .eq i { width: 2.5px; background: var(--brass); border-radius: 1px; animation: eq .9s ease-in-out infinite; }
.preview-btn .eq i:nth-child(2) { animation-delay: -.3s; } .preview-btn .eq i:nth-child(3) { animation-delay: -.6s; }
.preview-btn.playing { border-color: rgba(227,196,140,.5); background: rgba(227,196,140,.1); }
.preview-btn.playing .i-play { display: none; } .preview-btn.playing .eq { display: flex; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 11px; } }

.stats { display: grid; gap: 8px; margin: 0; }
.stat { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.025); border: 1px solid var(--line); }
.stat dt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.stat dt i { width: 8px; height: 8px; border-radius: 3px; }
.stat.rh dt i { background: var(--rh); box-shadow: 0 0 8px var(--rh-glow); }
.stat.lh dt i { background: var(--lh); box-shadow: 0 0 8px var(--lh-glow); }
.stat dd { margin: 0; text-align: right; display: grid; }
.stat dd b { font-weight: 600; font-size: 13px; }
.stat dd span { font-size: 11px; color: var(--text-3); }
.shortcuts ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.shortcuts li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: center; font-size: 12px; color: var(--text-3); }
kbd { justify-self: start; font: 500 10.5px/1 var(--f-mono); color: var(--text-2); padding: 4px 6px; border-radius: 6px; background: var(--ink-3); border: 1px solid var(--line-2); box-shadow: 0 1px 0 var(--ink-0); white-space: nowrap; }

/* ---------- score ---------- */
.s-score { position: relative; min-height: 0; background: radial-gradient(800px 300px at 50% 0%, rgba(227,196,140,.035), transparent 70%); }
.score-scroll { position: absolute; inset: 0; overflow: auto; padding: 22px clamp(16px, 2.4vw, 36px) 64px; scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent; }
.paper { position: relative; max-width: 1240px; margin: 0 auto; padding: 18px 14px 26px; border-radius: 6px; background: var(--paper);
  background-image: radial-gradient(1200px 400px at 50% -100px, #fffdf8, transparent), linear-gradient(180deg, #fbf8f1, #f6f1e5);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 30px 60px -30px rgba(0,0,0,.9), 0 10px 20px -10px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.4); }
.osmd-host { position: relative; min-height: 200px; cursor: pointer; }
.osmd-host svg { display: block; }
.score-cursor { border-radius: 4px; transition: left .09s linear; pointer-events: none; mix-blend-mode: multiply; }
.zoom { position: absolute; right: 18px; bottom: 14px; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(17,20,27,.86); border: 1px solid var(--line-2); backdrop-filter: blur(10px); box-shadow: var(--shadow-2); z-index: 3; }
.zoom .icon-btn { width: 28px; height: 28px; border-radius: 9px; }
.zoom .icon-btn svg { width: 14px; height: 14px; }
.zoom .mono { font-size: 11px; color: var(--text-2); min-width: 38px; text-align: center; }

.score-state { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(11,13,18,.72); backdrop-filter: blur(4px); animation: view-in .3s var(--ease) both; }
.score-state[hidden] { display: none; }
.score-state.soft { inset: auto 20px 20px 20px; background: none; backdrop-filter: none; place-items: end center; }
.ss-card { display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 380px; padding: 28px 30px; border-radius: 20px; background: rgba(23,27,36,.9); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); }
.ss-card h3 { font-size: 22px; }
.ss-card p { color: var(--text-2); font-size: 13.5px; }
.ss-card .btn { margin-top: 6px; }
.ss-spin { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(227,196,140,.08); border: 1px solid rgba(227,196,140,.18); }
.ss-spin .spinner { width: 22px; height: 22px; }
.score-state.loading { background: rgba(11,13,18,.55); }

/* ---------- falling notes ---------- */
.s-falling { position: relative; height: clamp(120px, 22vh, 300px); border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6,7,10,.2), rgba(6,7,10,.75)), repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.012) 39px 40px); }
.s-falling[hidden] { display: none; }
.fall-canvas { position: absolute; inset: 0 8px; width: calc(100% - 16px); height: 100%; display: block; }

/* ---------- transport ---------- */
.s-transport { position: relative; z-index: 3; padding: 0 20px; background: linear-gradient(180deg, rgba(23,27,36,.95), rgba(17,20,27,.98)); border-top: 1px solid var(--line-2);
  box-shadow: 0 -12px 30px -18px rgba(0,0,0,.8); }
.seek { position: relative; height: 18px; margin: 0 -2px; cursor: pointer; touch-action: none; outline: none; }
.seek-track { position: absolute; left: 2px; right: 2px; top: 7px; height: 4px; border-radius: 999px; background: rgba(236,226,206,.09); transition: top .18s var(--ease), height .18s var(--ease); }
.seek:hover .seek-track, .seek.drag .seek-track, .seek:focus-visible .seek-track { top: 6px; height: 6px; }
.seek-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--brass-2), var(--brass)); box-shadow: 0 0 12px var(--brass-glow); }
.seek-ticks i { position: absolute; top: -1px; bottom: -1px; width: 1px; background: rgba(236,226,206,.14); }
.seek-loop { position: absolute; top: -4px; bottom: -4px; border-radius: 4px; background: rgba(227,196,140,.16); border-left: 2px solid var(--brass); border-right: 2px solid var(--brass); }
.seek-loop.off { opacity: .45; border-style: dashed; }
.seek-head { position: absolute; top: 9px; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff6e4; box-shadow: 0 0 0 3px rgba(227,196,140,.35), 0 2px 6px rgba(0,0,0,.6); transform: scale(.0); transition: transform .18s var(--ease-spring); left: 0; }
.seek:hover .seek-head, .seek.drag .seek-head, .is-playing .seek-head, .seek:focus-visible .seek-head { transform: scale(1); }
.seek-tip { position: absolute; bottom: 22px; transform: translateX(-50%); padding: 5px 8px; border-radius: 8px; background: var(--ink-4); border: 1px solid var(--line-2); font-size: 11px; color: var(--text); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; box-shadow: var(--shadow-2); }
.seek:hover .seek-tip { opacity: 1; }

.t-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; height: 62px; }
.t-left, .t-right, .t-center { display: flex; align-items: center; gap: 12px; min-width: 0; }
.t-left, .t-right { flex: none; }
.t-center { justify-content: center; }
.t-right { justify-content: flex-end; }
.tempo { flex: none; }
.tempo .eyebrow { white-space: nowrap; }
.t-center { gap: 22px; }
.t-group { display: flex; align-items: center; gap: 10px; }
.t-group .eyebrow { font-size: 10px; }
.play-btn { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #1d160b;
  background: radial-gradient(circle at 50% 30%, #f3dcae, #d2ad6c 70%); box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 8px 22px -6px rgba(227,196,140,.6), 0 0 0 1px rgba(255,230,180,.35);
  transition: transform .2s var(--ease-spring), box-shadow .2s; flex: none; }
.play-btn:hover { transform: scale(1.05); }
.play-btn:active { transform: scale(.96); }
.play-btn svg { width: 20px; height: 20px; }
.play-btn .i-play { margin-left: 2px; }
.play-btn .i-pause, .play-btn.on .i-play { display: none; }
.play-btn.on .i-pause { display: block; }
.play-btn.on { box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 0 0 6px rgba(227,196,140,.12), 0 8px 26px -6px rgba(227,196,140,.8); }
.t-clock { display: grid; gap: 3px; margin-left: 6px; min-width: 0; }
.t-time { display: flex; align-items: baseline; gap: 6px; font-size: 15px; white-space: nowrap; }
.t-now { color: var(--text); font-weight: 500; }
.t-sep, .t-total { color: var(--text-3); font-size: 13px; }
.t-bar { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.loop-group { position: relative; }
.loop-ctl { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px; background: var(--ink-0); border: 1px solid var(--line-2); }
.loop-pt { width: 30px; height: 30px; border-radius: 9px; border: 0; background: none; cursor: pointer; font: 600 12px/1 var(--f-mono); color: var(--text-3); transition: all .15s; }
.loop-pt:hover { color: var(--text); background: rgba(255,255,255,.05); }
.loop-pt.set { color: var(--brass); }
.loop-ctl .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
.loop-ctl .icon-btn svg { width: 16px; height: 16px; }
.loop-read { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--brass); min-width: 0; white-space: nowrap; }
.loop-read:empty { display: none; }
.loop-clear { width: 18px; height: 18px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.loop-clear:hover { color: var(--text); background: rgba(255,255,255,.06); }
.loop-clear svg { width: 12px; height: 12px; }

.tempo { display: flex; align-items: center; gap: 10px; cursor: default; }
.tempo input[type=range] { --p: 60%; appearance: none; width: clamp(80px, 8vw, 130px); height: 18px; background: none; cursor: pointer; }
.tempo input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--brass) var(--p), rgba(236,226,206,.12) var(--p)); }
.tempo input[type=range]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff6e4; box-shadow: 0 0 0 3px rgba(227,196,140,.3), 0 2px 5px rgba(0,0,0,.5); transition: transform .15s var(--ease-spring); }
.tempo input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.15); }
.tempo input[type=range]::-moz-range-track { height: 4px; border-radius: 999px; background: rgba(236,226,206,.12); }
.tempo input[type=range]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--brass); }
.tempo input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff6e4; }
.tempo-read { display: grid; line-height: 1.15; min-width: 52px; }
.tempo-val { font-size: 13.5px; color: var(--text); font-weight: 500; }
.tempo-bpm { font-size: 10.5px; color: var(--text-3); }
.t-toggles { display: flex; gap: 2px; padding-left: 10px; border-left: 1px solid var(--line); }
.piano-status { position: absolute; right: 20px; bottom: calc(100% + 10px); height: 28px; padding: 0 11px; border-radius: 999px; background: rgba(23,27,36,.92); border: 1px solid var(--line-2); display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); white-space: nowrap; transition: opacity .5s; }
.piano-status .spinner { width: 13px; height: 13px; border-width: 1.5px; }
.piano-status.ready { opacity: 0; }
.piano-status.error { color: var(--danger); }
.piano-status svg { width: 14px; height: 14px; }
.piano-status[hidden] { display: none; }

/* ---------- piano ---------- */
.s-piano { position: relative; height: min(11.5vw, 18vh, 190px); min-height: 96px; padding: 0 8px 8px; background: linear-gradient(180deg, #0d0e12, #07080a); }
.felt { position: absolute; left: 0; right: 0; top: 0; height: 7px; z-index: 3; background: linear-gradient(180deg, #6b1f2a, #461219 60%, #2c0a10); box-shadow: 0 2px 4px rgba(0,0,0,.7); }
.felt::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 2px, transparent 2px 4px); }
.piano { position: relative; height: 100%; user-select: none; -webkit-user-select: none; touch-action: none; }
.piano-keys { position: absolute; inset: 0; }
.key { position: absolute; top: 0; box-sizing: border-box; cursor: pointer; }
.key.white { bottom: 0; border-right: 1px solid transparent; background-clip: padding-box; z-index: 1; border-radius: 0 0 5px 5px;
  background-color: var(--ivory);
  background-image: linear-gradient(180deg, #d9d0bd 0, #efe8da 9px, #f8f3e8 40%, #fffcf5 100%);
  box-shadow: inset 0 -6px 0 #ddd3bf, inset 1px 0 0 rgba(255,255,255,.7), inset -1px 0 0 rgba(0,0,0,.08);
  transition: background .06s, box-shadow .06s, transform .06s; }
.key.black { height: 63%; z-index: 2; border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, #121317 0%, #26282e 80%, #3a3c43 88%, #18191d 100%);
  box-shadow: 0 4px 6px rgba(0,0,0,.55), inset 0 -4px 0 rgba(255,255,255,.06), inset 1px 0 0 rgba(255,255,255,.06), inset -1px 0 0 rgba(0,0,0,.6);
  transition: background .06s, box-shadow .06s; }
.key:hover.white { background-image: linear-gradient(180deg, #d9d0bd 0, #efe8da 9px, #fbf6ea 40%, #fffdf8 100%); }
.key:hover.black { background: linear-gradient(180deg, #17181d 0%, #2f3139 80%, #44464e 88%, #1d1e23 100%); }

/* lit by playback */
.key.white.on.rh { background-image: linear-gradient(180deg, #c7583a 0, #f28a68 12px, #ffae92 70%, #ffc3ae 100%); box-shadow: inset 0 -3px 0 #d8603e, 0 0 24px 2px var(--rh-glow); }
.key.white.on.lh { background-image: linear-gradient(180deg, #218d80 0, #45bdb0 12px, #7fe0d5 70%, #a2ece3 100%); box-shadow: inset 0 -3px 0 #2c9d8f, 0 0 24px 2px var(--lh-glow); }
.key.black.on.rh { background: linear-gradient(180deg, #8f3620, #e0603d 70%, #f07a58 88%, #b24a2c); box-shadow: 0 2px 3px rgba(0,0,0,.5), 0 0 18px 2px var(--rh-glow); }
.key.black.on.lh { background: linear-gradient(180deg, #16665c, #2ea596 70%, #45bfb1 88%, #227d71); box-shadow: 0 2px 3px rgba(0,0,0,.5), 0 0 18px 2px var(--lh-glow); }
/* ghost lights for the muted hand */
.key.white.on.ghost.rh { background-image: linear-gradient(180deg, #d9d0bd 0, #f3e3da 12px, #fbeee7 100%); box-shadow: inset 0 -6px 0 #ddd3bf, inset 0 0 0 2px rgba(240,118,80,.7); }
.key.white.on.ghost.lh { background-image: linear-gradient(180deg, #d9d0bd 0, #e2eeea 12px, #eef7f4 100%); box-shadow: inset 0 -6px 0 #ddd3bf, inset 0 0 0 2px rgba(46,165,150,.75); }
.key.black.on.ghost.rh { background: linear-gradient(180deg, #121317, #3a2621 85%, #18191d); box-shadow: 0 4px 6px rgba(0,0,0,.55), inset 0 0 0 1.5px rgba(255,145,112,.75); }
.key.black.on.ghost.lh { background: linear-gradient(180deg, #121317, #1f3634 85%, #18191d); box-shadow: 0 4px 6px rgba(0,0,0,.55), inset 0 0 0 1.5px rgba(95,211,198,.75); }
/* pressed by the user (mouse / computer keyboard) */
.key.white.pressed { background-image: linear-gradient(180deg, #b69a64 0, #e6cb95 12px, #f2dcb0 70%, #f7e7c5 100%); box-shadow: inset 0 -3px 0 #cfae6f, 0 0 22px 2px var(--brass-glow); }
.key.black.pressed { background: linear-gradient(180deg, #6e5630, #c9a263 75%, #e3c48c 88%, #8b6d3c); }
.key.on.white:not(.ghost), .key.pressed.white { transform: translateY(1px); }
.klabel { position: absolute; left: 0; right: 0; bottom: 9px; text-align: center; font: 500 9px/1 var(--f-mono); color: #a2998a; pointer-events: none; }
.middle-c .klabel { color: #7d6a45; font-weight: 600; }
.key.on .klabel, .key.pressed .klabel { color: rgba(40,20,10,.55); }
.khint { position: absolute; left: 0; right: 0; bottom: 24px; text-align: center; font: 600 10px/1 var(--f-ui); color: #6f5a35; pointer-events: none; display: none; }
.key.black .khint { bottom: 8px; color: var(--brass); }
.piano.show-hints .khint { display: block; }
.piano.show-hints .key.white.mapped { box-shadow: inset 0 -6px 0 #ddd3bf, inset 0 -8px 0 0 rgba(201,162,99,.0), inset 0 3px 0 rgba(201,162,99,.0); }
.piano.show-hints .key.white.mapped::after { content: ""; position: absolute; left: 25%; right: 25%; bottom: 3px; height: 2px; border-radius: 2px; background: rgba(201,162,99,.8); }
.piano-readout { position: absolute; left: 50%; top: -128px; transform: translate(-50%, 6px); padding: 6px 12px; border-radius: 10px; background: rgba(23,27,36,.95); border: 1px solid var(--line-2);
  font-size: 12px; color: var(--brass); white-space: pre; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 6; box-shadow: var(--shadow-2); }
.piano-readout.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1360px) {
  .s-body { grid-template-columns: 256px minmax(0, 1fr); }
  .t-group .eyebrow { display: none; }
  .t-center { gap: 14px; }
  .s-top-center .eyebrow { display: none; }
  .tempo .eyebrow { display: none; }
}
@media (max-width: 1180px) {
  .seg button { padding: 0 11px; }
  .tempo .eyebrow { display: none; }
  .s-meta .meta-item:last-child { display: none; }
}
@media (max-height: 880px) {
  .shortcuts { display: none; }
}

/* Editable base tempo and time signature in the header meta line */
.s-meta .meta-edit, .s-meta .meta-select {
  font: inherit; color: var(--text-2); background: transparent; border: 1px solid transparent; border-radius: 6px;
  height: 20px; padding: 0 5px; margin: 0 -2px; cursor: pointer; line-height: 18px;
  transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.s-meta .meta-edit { text-decoration: underline dotted rgba(227,196,140,.45); text-underline-offset: 3px; }
.s-meta .meta-edit:hover, .s-meta .meta-select:hover { color: var(--text); border-color: var(--line-2); background-color: rgba(255,255,255,.03); }
.s-meta .meta-edit.set, .s-meta .meta-select.set { color: var(--brass); }
.s-meta .meta-select {
  appearance: none; -webkit-appearance: none; padding-right: 16px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%23b1ab9f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center;
}
.s-meta .meta-select option { background: #12151c; color: #e9e3d6; }
.s-meta .meta-editing { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }
.s-meta .meta-input {
  width: 52px; height: 20px; padding: 0 5px; border-radius: 6px; border: 1px solid rgba(227,196,140,.45);
  background: var(--ink-0); color: var(--text); font: inherit; outline: none; box-shadow: 0 0 0 3px var(--brass-glow);
}
.s-meta .meta-input::-webkit-inner-spin-button { opacity: .4; }

/* octave fix (a missed 8va / 8vb) */
.oct-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.oct-row .seg { flex: 0 0 auto; }
.oct-range { font-size: 11px; color: var(--text-3); }
.oct-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.oct-list li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.oct-list li .mono { flex: 1; }
.oct-tag { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 99px; }
.oct-tag.rh { background: color-mix(in srgb, var(--rh) 22%, transparent); color: var(--rh); }
.oct-tag.lh { background: color-mix(in srgb, var(--lh) 22%, transparent); color: var(--lh); }
.seek-ticks i.repeat { background: var(--brass, #e3c48c); opacity: .7; }
.meta-soft { opacity: .7; font-style: italic; }

/* =====================================================================
   v2: practice, MIDI, score interactions, polish
   ===================================================================== */

/* ---------- score overlays: current bar, loop / drag selection, clicked note ---------- */
.score-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.bar-hl { position: absolute; left: 0; top: 0; border-radius: 8px; background: rgba(227,196,140,.13); box-shadow: inset 0 0 0 1px rgba(201,162,99,.28);
  mix-blend-mode: multiply; transition: transform .22s var(--ease), width .22s var(--ease), height .22s var(--ease), opacity .2s; }
.sel-band { position: absolute; left: 0; top: 0; border-radius: 8px; mix-blend-mode: multiply; }
.sel-band.loop { background: rgba(95,211,198,.16); box-shadow: inset 0 0 0 1.5px rgba(46,165,150,.55); }
.sel-band.loop.off { background: rgba(95,211,198,.06); box-shadow: inset 0 0 0 1.5px rgba(46,165,150,.3); }
.sel-band.drag { background: rgba(227,196,140,.22); box-shadow: inset 0 0 0 1.5px rgba(201,162,99,.8); }
.note-pulse { position: absolute; left: 0; top: 0; border-radius: 10px; box-shadow: 0 0 0 2px rgba(240,118,80,.8); animation: note-pulse .9s var(--ease) both; }
@keyframes note-pulse { from { opacity: 1; box-shadow: 0 0 0 2px rgba(240,118,80,.9), 0 0 0 0 rgba(240,118,80,.35); } to { opacity: 0; box-shadow: 0 0 0 2px rgba(240,118,80,0), 0 0 0 14px rgba(240,118,80,0); } }
.s-score.dragging-bars .osmd-host { cursor: col-resize; }
.osmd-host.swap-in > div:not(.score-layer) { animation: swap-in .45s var(--ease) both; }
@keyframes swap-in { from { opacity: 0; filter: blur(3px); } }
.osmd-host { transition: opacity .25s var(--ease), filter .25s var(--ease); }
.s-score.reloading .osmd-host { opacity: .42; filter: saturate(.6) blur(.6px); pointer-events: none; }
.busy-chip { position: absolute; top: 14px; left: 50%; z-index: 5; transform: translate(-50%, -6px); display: inline-flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 14px 0 12px; border-radius: 999px; background: rgba(23,27,36,.94); border: 1px solid rgba(227,196,140,.3); box-shadow: var(--shadow-3);
  font-size: 12.5px; font-weight: 600; color: var(--text); opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--ease-spring); }
.busy-chip::before { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid rgba(227,196,140,.25); border-top-color: var(--brass); animation: spin .8s linear infinite; }
.s-score.reloading .busy-chip { opacity: 1; transform: translate(-50%, 0); }

/* ---------- first-load skeleton ---------- */
.score-state.skeleton { background: none; backdrop-filter: none; place-items: start center; padding: 22px clamp(16px, 2.4vw, 36px) 0; overflow: hidden; }
.sk-paper { width: min(100%, 1240px); padding: 34px 44px; border-radius: 6px; background: linear-gradient(180deg, #f6f1e5, #f1ebdd);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.4); display: grid; gap: 34px; position: relative; overflow: hidden; }
.sk-paper::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 35%, rgba(255,255,255,.4) 50%, transparent 65%); transform: translateX(-100%); animation: shimmer 1.6s ease-in-out infinite; }
.score-state.skeleton ~ .zoom, .s-score:has(.score-state.skeleton:not([hidden])) .zoom { visibility: hidden; }
.sk-title { width: 34%; height: 16px; border-radius: 6px; background: rgba(28,26,22,.1); justify-self: center; }
.sk-system { display: grid; gap: 22px; }
.sk-staff { display: grid; gap: 7px; }
.sk-staff i { height: 1.5px; background: rgba(28,26,22,.16); }
.sk-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: rgba(23,27,36,.92); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); font-size: 13px; font-weight: 600; }
.sk-label .spinner { width: 15px; height: 15px; }

/* ---------- score toolbar (follow + zoom) ---------- */
.zoom-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 3px; }
.follow-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border: 0; border-radius: 9px; background: none; cursor: pointer;
  font: 600 11.5px/1 var(--f-ui); color: var(--text-3); transition: color .15s, background .15s; }
.follow-btn svg { width: 15px; height: 15px; }
.follow-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }
.follow-btn[aria-pressed="true"] { color: var(--brass); background: rgba(227,196,140,.1); }

/* ---------- count-in ---------- */
.count-in { position: absolute; left: 50%; top: 50%; z-index: 6; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; display: grid; place-items: center; align-content: center; gap: 4px; pointer-events: none;
  background: radial-gradient(circle at 50% 35%, rgba(35,40,52,.96), rgba(17,20,27,.96)); border: 1px solid rgba(227,196,140,.35); box-shadow: var(--shadow-3), 0 0 0 10px rgba(227,196,140,.06), 0 0 60px -10px var(--brass-glow); }
.count-in[hidden] { display: none; }
.ci-n { font: 300 76px/.9 var(--f-display); color: var(--brass); text-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 60px var(--brass-glow); font-variation-settings: "opsz" 144; }
.ci-sub { font: 600 11px/1 var(--f-ui); letter-spacing: .2em; text-transform: uppercase; color: var(--text-2); min-height: 11px; }
.count-in.tick .ci-n { animation: ci-tick .5s var(--ease-spring) both; }
@keyframes ci-tick { from { transform: scale(1.35); opacity: 0; } 40% { opacity: 1; } }

/* ---------- practice ---------- */
.practice-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--ink-0); color: var(--text-2); font: 600 12.5px/1 var(--f-ui);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.5); transition: color .18s, background .18s, border-color .18s, box-shadow .25s; }
.practice-btn svg { width: 17px; height: 17px; }
.practice-btn:hover { color: var(--text); border-color: var(--line-3); }
.practice-btn[aria-pressed="true"] { color: #1d160b; border-color: rgba(255,230,180,.5); background: linear-gradient(180deg, #ecd3a2, #d2ad6c);
  box-shadow: 0 1px 0 rgba(255,255,255,.45) inset, 0 6px 18px -6px rgba(227,196,140,.6); }
.is-waiting .play-btn { animation: wait-ring 1.4s ease-in-out infinite; }
@keyframes wait-ring { 50% { box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 0 0 9px rgba(227,196,140,.1), 0 8px 26px -6px rgba(227,196,140,.8); } }

.practice-hud { position: absolute; left: 18px; bottom: 14px; z-index: 4; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 300px); padding: 8px 8px 8px 14px;
  border-radius: 16px; background: rgba(17,20,27,.93); border: 1px solid rgba(227,196,140,.24); backdrop-filter: blur(12px); box-shadow: var(--shadow-3);
  animation: view-in .3s var(--ease) both; }
.practice-hud[hidden] { display: none; }
.hud-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-badge { display: inline-flex; align-items: center; gap: 6px; flex: none; font: 600 10.5px/1 var(--f-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--brass); }
.hud-badge svg { width: 14px; height: 14px; }
.hud-need { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; min-width: 0; min-height: 24px; }
.hud-label { font-size: 12.5px; color: var(--text-2); margin-right: 2px; }
.hud-note { font: 600 12px/1 var(--f-mono); padding: 5px 8px; border-radius: 8px; border: 1px solid; animation: ci-tick .35s var(--ease-spring) both; }
.hud-note.rh { color: var(--rh); border-color: rgba(255,145,112,.45); background: rgba(255,145,112,.1); }
.hud-note.lh { color: var(--lh); border-color: rgba(95,211,198,.45); background: rgba(95,211,198,.1); }
.hud-note.hit { color: #0d1a12; background: var(--ok); border-color: var(--ok); }
.hud-stats { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); padding-left: 14px; border-left: 1px solid var(--line); flex: none; }
.hud-stat { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.hud-stat b { color: var(--text); font-weight: 500; font-size: 12.5px; }
.hud-stat i { width: 7px; height: 7px; border-radius: 2px; }
.hud-stat.rh i { background: var(--rh); } .hud-stat.lh i { background: var(--lh); }
.hud-stat.dim { opacity: .4; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.sm svg { width: 14px; height: 14px; }

/* piano feedback: expected (practice), right, wrong */
.piano .key.expect.white, .piano .key.expect.white.on { box-shadow: inset 0 -6px 0 #ddd3bf, inset 0 0 0 2px rgba(227,196,140,.95), 0 0 18px 2px var(--brass-glow); animation: expect 1.1s ease-in-out infinite; }
.piano .key.expect.black, .piano .key.expect.black.on { box-shadow: 0 4px 6px rgba(0,0,0,.55), inset 0 0 0 2px rgba(227,196,140,.95), 0 0 14px 2px var(--brass-glow); animation: expect 1.1s ease-in-out infinite; }
@keyframes expect { 50% { filter: brightness(1.12); } }
.key.white.good { background-image: linear-gradient(180deg, #4e9a6a 0, #8fdcaa 14px, #b9ecca 70%, #d3f5de 100%) !important; box-shadow: inset 0 -3px 0 #5cae7c, 0 0 26px 3px rgba(143,220,170,.55) !important; }
.key.black.good { background: linear-gradient(180deg, #2f6b45, #5cae7c 70%, #8fdcaa 88%, #3f7f57) !important; box-shadow: 0 0 20px 3px rgba(143,220,170,.55) !important; }
.key.white.bad { background-image: linear-gradient(180deg, #a3443d 0, #ff8f86 14px, #ffb4ad 70%, #ffc9c4 100%) !important; box-shadow: inset 0 -3px 0 #d0564d, 0 0 22px 2px rgba(255,122,112,.5) !important; animation: shake .28s ease-in-out; }
.key.black.bad { background: linear-gradient(180deg, #6e1f1a, #d0564d 70%, #ff7a70 88%, #8c2a24) !important; animation: shake .28s ease-in-out; }
@keyframes shake { 25% { translate: -1.5px 0; } 75% { translate: 1.5px 0; } }

/* piano samples loading: a slow sheen across the keys */
.s-piano::after { content: ""; position: absolute; inset: 7px 8px 8px; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .6s;
  background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%); background-size: 60% 100%; background-repeat: no-repeat; }
.piano-loading .s-piano::after { opacity: 1; animation: key-sheen 1.8s ease-in-out infinite; }
@keyframes key-sheen { from { background-position: -80% 0; } to { background-position: 190% 0; } }

/* MIDI button: a dot when a keyboard is live */
.midi-btn { position: relative; }
.midi-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); opacity: 0; transition: opacity .2s; }
.midi-btn[aria-pressed="true"] .midi-dot { opacity: 1; background: var(--brass); }
.midi-btn.live .midi-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(143,220,170,.2); }
.midi-btn.unsupported { opacity: .5; }

/* falling-notes chip */
.fall-chip { position: absolute; top: 8px; right: 16px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(11,13,18,.7); backdrop-filter: blur(6px); color: var(--text-3); font: 600 11.5px/1 var(--f-ui); transition: color .15s, border-color .15s, background .15s; }
.fall-chip svg { width: 15px; height: 15px; }
.fall-chip:hover { color: var(--text); border-color: var(--line-3); }
.fall-chip[aria-pressed="true"] { color: var(--brass); border-color: rgba(227,196,140,.35); background: rgba(227,196,140,.1); }

.tempo-val.bump { animation: bump .5s var(--ease-spring); color: var(--brass); }
@keyframes bump { 40% { transform: scale(1.18); } }

/* focus: visible rings everywhere, inset on tight controls */
.seg button:focus-visible, .loop-pt:focus-visible, .loop-ctl .icon-btn:focus-visible { outline-offset: -2px; border-radius: 999px; }
.seek:focus-visible .seek-track { box-shadow: 0 0 0 2px var(--brass); }
.part-row:focus-within { outline: none; }
.meta-select:focus-visible, .meta-edit:focus-visible { outline-offset: 1px; }

/* layout at laptop sizes: give the score more room */
@media (max-height: 900px) {
  .s-falling { height: clamp(96px, 17vh, 200px); }
  .s-piano { height: min(11vw, 16vh, 170px); }
}
@media (max-width: 1440px) { .meta-soft { display: none; } }
@media (max-width: 1360px) { .loop-read { display: none; } }
@media (max-width: 1200px) {
  .practice-btn span { display: none; }
  .practice-btn { width: 36px; padding: 0; justify-content: center; }
  .t-center { gap: 12px; }
}
@media (max-width: 1000px) {
  .t-row { gap: 10px; }
  .t-center { gap: 8px; }
  .t-clock { margin-left: 0; }
  .t-right { gap: 8px; }
  .tempo { gap: 6px; }
  .tempo input[type=range] { width: 72px; }
  .tempo-read { min-width: 0; }
  .tempo-bpm { display: none; }
  .t-toggles { padding-left: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar-hl, .osmd-host { transition: none; }
  .piano-loading .s-piano::after, .sk-paper::after, .key.expect { animation: none !important; }
}

/* tooltips (ui.js installTips) */
.tip { position: fixed; z-index: 300; max-width: 280px; padding: 6px 9px; border-radius: 8px; pointer-events: none; display: inline-flex; align-items: center; gap: 8px;
  background: #262c39; border: 1px solid var(--line-3); box-shadow: 0 8px 24px -6px rgba(0,0,0,.7); font: 500 12px/1.35 var(--f-ui); color: var(--text);
  opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .15s var(--ease); }
.tip.below { transform: translateY(-3px); }
.tip.in { opacity: 1; transform: none; }
.tip kbd { font-size: 10px; padding: 3px 5px; background: var(--ink-1); }
