/* Halawi Keys - styles */
:root {
  --violet: #9b3df5; --magenta: #c84fb4; --coral: #ea6a5a;
  --grad: linear-gradient(100deg, #9b3df5 0%, #c84fb4 55%, #ea6a5a 100%);
  --bg: #0a0a0c; --bg-1: #0d0d11; --bg-2: #121217; --bg-3: #17171e; --bg-4: #1d1d26;
  --glass: rgba(255,255,255,.028); --glass-2: rgba(255,255,255,.045); --glass-3: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.075); --line-2: rgba(255,255,255,.12); --line-3: rgba(255,255,255,.18);
  --text: #eeedf3; --text-2: #cbc5d4; --muted: #9c95a8; --dim: #6f6979;
  --accent: #b46cff; --bad: #ef5b62; --ok: #3fb68b;
  --focus: 0 0 0 2px rgba(180,108,255,.75);
  --f-ui: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-data: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --toph: 56px; --kbw: 260px;
  --hl: #a35cff; --hr: #f08a6e;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--f-data); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 500; background: var(--bg-3); padding: 8px 12px; border-radius: 8px; color: var(--text); border: 1px solid var(--line-2); }
.skip:focus { top: 10px; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; z-index: 999; background: var(--bg); font: 500 16px var(--f-ui); padding: 24px; text-align: center; }
.ic { width: 18px; height: 18px; flex: none; }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--glass-2); font: 500 11.5px/1.5 var(--f-data); color: var(--text-2); text-align: center; }

/* ---------- shell ---------- */
.app { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); min-height: 56px; background: linear-gradient(180deg, #111116, #0c0c10); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--grad); opacity: .35; }
.brand { display: flex; align-items: center; flex: none; }
.brand img { height: 26px; width: auto; display: block; }
.appname { font: 600 17px/1 var(--f-ui); letter-spacing: -.01em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding-left: 2px; }
.sep { width: 1px; height: 26px; background: var(--line-2); flex: none; }
.grow { flex: 1; }
.brk { display: none; }
.input { height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background-color: var(--glass-2); padding: 0 10px; color: var(--text); outline: none; }
.input--sm { height: 32px; font: 500 13px var(--f-ui); }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239c95a8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; cursor: pointer; }
select.input option { background: #17171e; color: var(--text); }
.input:hover { border-color: var(--line-3); }
.sel-inst { min-width: 158px; }
.transport, .metro { display: flex; align-items: center; gap: 6px; flex: none; }
.tbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--glass-2); display: grid; place-items: center; cursor: pointer; color: var(--text-2); transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.tbtn:hover { background: var(--glass-3); color: var(--text); border-color: var(--line-3); }
.tbtn.rec { color: #ff6b74; }
.tbtn.rec.on { background: rgba(239,91,98,.2); border-color: rgba(239,91,98,.7); box-shadow: 0 0 0 3px rgba(239,91,98,.15), 0 0 18px rgba(239,91,98,.35); animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 5px rgba(239,91,98,.08), 0 0 24px rgba(239,91,98,.5); } }
.tbtn.on { color: #fff; background: rgba(155,61,245,.22); border-color: rgba(155,61,245,.6); }
.clock { font: 500 13px/1 var(--f-data); font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 54px; padding: 0 4px; }
body.recording .clock { color: #ff8d92; }
.beats { display: flex; gap: 4px; padding: 0 2px; }
.beats i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); transition: background .05s; }
.beats i.on { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.beats i.on.acc { background: var(--coral); box-shadow: 0 0 10px var(--coral); }
.num { width: 58px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--glass-2); text-align: center; font: 500 13px var(--f-data); font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.num::-webkit-inner-spin-button, .num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.unit { font: 500 11px var(--f-ui); color: var(--muted); letter-spacing: .04em; }
.sig { width: 72px; }
.meter { display: flex; gap: 3px; height: 26px; align-items: flex-end; padding: 0 4px; }
.meter i { width: 4px; height: 100%; border-radius: 2px; background: linear-gradient(0deg, var(--violet), var(--magenta) 60%, var(--coral)); transform-origin: bottom; transform: scaleY(.02); transition: transform .06s linear; opacity: .9; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; flex: none; position: relative; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--glass-2); color: var(--text); border-color: var(--line); }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm .ic { width: 15px; height: 15px; }
.midi-ind .dot { position: absolute; right: 6px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.midi-ind.connected { color: var(--text-2); }
.midi-ind.connected .dot { background: var(--ok); }
.midi-ind.activity .dot { background: var(--coral); box-shadow: 0 0 8px var(--coral); }
.nav { display: flex; gap: 4px; }
.navbtn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); font: 500 13px/1 var(--f-ui); cursor: pointer; position: relative; transition: background .15s, border-color .15s; }
.navbtn:hover { background: var(--glass-2); border-color: var(--line); }
.navbtn.on { background: rgba(155,61,245,.16); border-color: rgba(155,61,245,.45); color: #fff; }
.pip { position: absolute; top: -4px; right: -4px; min-width: 15px; height: 15px; border-radius: 10px; background: var(--coral); color: #fff; font: 600 9.5px/15px var(--f-ui); padding: 0 4px; text-align: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text); font: 500 13px/1 var(--f-ui); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s; }
.btn:hover { background: var(--glass-3); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: linear-gradient(100deg, #8f37ee, #b146c9 60%, #d75f78); border-color: transparent; color: #fff; box-shadow: 0 6px 20px -8px rgba(155,61,245,.75), inset 0 1px 0 rgba(255,255,255,.18); }
.btn--primary:hover { filter: brightness(1.08); background: linear-gradient(100deg, #8f37ee, #b146c9 60%, #d75f78); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--glass-2); border-color: var(--line); }
.btn--danger { background: rgba(239,91,98,.14); border-color: rgba(239,91,98,.45); color: #ff8d92; }
.btn--danger:hover { background: rgba(239,91,98,.24); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn--sm .ic { width: 15px; height: 15px; }
.btn--lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 11px; }
.btn:disabled { opacity: .5; cursor: progress; }

/* ---------- quick controls ---------- */
.controls { display: flex; align-items: center; gap: 12px; padding: 6px 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); min-height: 46px; background: #0d0d11; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; white-space: nowrap; position: relative; z-index: 15; }
.controls::-webkit-scrollbar { display: none; }
.ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.ctl label, .stepper .lbl { font: 500 11px/1 var(--f-ui); color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.ctl output { font: 500 12px var(--f-data); color: var(--text-2); min-width: 22px; font-variant-numeric: tabular-nums; }
.ctl.scale select { height: 30px; }
#q-root { width: 66px; } #q-scale { width: 138px; }
.row2 { display: flex; gap: 8px; } .row2 select { flex: 1; } .row2 select:first-of-type { flex: 0 0 84px; }
.vsep { width: 1px; height: 22px; background: var(--line); flex: none; }
.rng { -webkit-appearance: none; appearance: none; width: 78px; height: 22px; background: transparent; cursor: pointer; margin: 0; }
.rng--full { width: 100%; }
.rng::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(155,61,245,.85), rgba(200,79,180,.85) 60%, rgba(234,106,90,.85)); }
.rng::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(155,61,245,.85), rgba(200,79,180,.85) 60%, rgba(234,106,90,.85)); }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 3px rgba(155,61,245,.35), 0 2px 6px rgba(0,0,0,.5); }
.rng::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 3px rgba(155,61,245,.35), 0 2px 6px rgba(0,0,0,.5); }
.rng:focus-visible { box-shadow: none; }
.rng:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(180,108,255,.8); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 9px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text-2); font: 500 12.5px/1 var(--f-ui); cursor: pointer; flex: none; transition: all .15s; }
.pill .ic { width: 16px; height: 16px; }
.pill.on { background: linear-gradient(100deg, rgba(155,61,245,.35), rgba(200,79,180,.3)); border-color: rgba(200,79,180,.7); color: #fff; box-shadow: 0 0 16px -2px rgba(155,61,245,.6); }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper .lbl { margin-right: 4px; }
.stepper button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text-2); display: grid; place-items: center; cursor: pointer; padding: 0; }
.stepper button:hover { background: var(--glass-3); color: var(--text); }
.stepper button .ic { width: 14px; height: 14px; }
.stepper output { min-width: 30px; text-align: center; font: 600 12.5px var(--f-ui); color: var(--text); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; padding: 3px; background: var(--glass-2); border: 1px solid var(--line); border-radius: 9px; gap: 2px; flex: none; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font: 500 12px var(--f-ui); }
.seg button:hover { color: var(--text-2); }
.seg button.on { background: var(--bg-4); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 0 0 1px rgba(155,61,245,.35); }
.seg--full { display: flex; width: 100%; }
.seg--full button { flex: 1; padding: 7px 8px; font-size: 12.5px; }

/* ---------- stage / visualizer ---------- */
.stage { position: relative; overflow: hidden; min-height: 0; background:
  radial-gradient(900px 420px at 80% 0%, rgba(155,61,245,.13), transparent 60%),
  radial-gradient(700px 380px at 10% 100%, rgba(234,106,90,.08), transparent 60%),
  radial-gradient(600px 300px at 50% 110%, rgba(200,79,180,.10), transparent 70%),
  linear-gradient(180deg, #0b0b0f, #0e0d13); }
.stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px); background-size: 100% 48px; mask-image: linear-gradient(180deg, transparent, #000 40%, #000); -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, #000); }
#viz { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.readout { position: absolute; left: 16px; top: 14px; z-index: 3; padding: 10px 16px 11px; border-radius: 14px; background: rgba(14,14,19,.62); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-width: 170px; max-width: min(360px, 60%); pointer-events: none; transition: border-color .2s, box-shadow .2s, opacity .3s; }
.readout.live { border-color: rgba(155,61,245,.45); box-shadow: 0 0 30px -10px rgba(155,61,245,.6); }
.readout.dim { opacity: .55; }
.ro-name { font: 600 24px/1.15 var(--f-ui); letter-spacing: -.01em; background: linear-gradient(100deg, #fff, #e9d7ff 60%, #ffc9bd); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout.live .ro-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; }
.ro-detail { font: 400 12px/1.4 var(--f-data); color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idle { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); z-index: 2; color: var(--muted); font: 400 14px/1.6 var(--f-ui); text-align: center; pointer-events: none; transition: opacity .6s; width: min(560px, 86%); }
.idle kbd { font-size: 11px; }
.idle.gone { opacity: 0; }
.count { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 4; font: 600 96px/1 var(--f-ui); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; pointer-events: none; opacity: 0; }
.count.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { opacity: .95; transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: .15; transform: translate(-50%, -50%) scale(.95); } }
.hire { position: absolute; right: 14px; bottom: 12px; z-index: 3; font: 400 12px/1 var(--f-ui); color: var(--muted); padding: 7px 11px; border-radius: 20px; background: rgba(14,14,19,.55); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: color .15s, border-color .15s; }
.hire b { font-weight: 500; color: var(--text-2); }
.hire:hover { color: var(--text); border-color: rgba(200,79,180,.5); }
.hire:hover b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rotate { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 9px 8px 9px 12px; border-radius: 12px; background: rgba(23,23,30,.92); border: 1px solid rgba(155,61,245,.4); font: 400 12.5px/1.4 var(--f-ui); color: var(--text-2); }
.rotate > .ic { width: 22px; height: 22px; color: var(--accent); }
.rotate span { flex: 1; }
.rotate[hidden] { display: none; }
.learn-hud { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 5; width: min(540px, calc(100% - 32px)); padding: 12px 14px; border-radius: 14px; background: rgba(14,14,19,.78); border: 1px solid rgba(155,61,245,.35); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 40px -12px rgba(0,0,0,.7); }
.learn-hud[hidden] { display: none; }
.lh-top { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
.lh-top strong { font: 600 15px/1.2 var(--f-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lh-mode { font: 500 11px var(--f-ui); color: var(--muted); white-space: nowrap; }
.lh-bar { height: 4px; border-radius: 4px; background: var(--glass-3); margin: 9px 0 7px; overflow: hidden; }
.lh-bar i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 4px; }
.lh-stats { display: flex; justify-content: space-between; gap: 10px; font: 400 12px var(--f-data); color: var(--text-2); }
#lh-hint { color: #ffd2c8; font-weight: 500; text-align: right; }
.lh-actions { display: flex; gap: 6px; margin-top: 9px; }
body.learning .readout { top: auto; bottom: 14px; }
body.learning .idle { display: none; }
body.learning .readout:not(.live) { opacity: 0; }

/* ---------- keyboard ---------- */
.kb-wrap { position: relative; z-index: 10; background: linear-gradient(180deg, #0c0b10, #08080a); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.navstrip { display: flex; align-items: center; gap: 6px; height: 24px; padding: 3px 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
.ns-btn { width: 22px; height: 18px; border-radius: 5px; border: 1px solid var(--line); background: var(--glass); color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; flex: none; }
.ns-btn:hover { color: var(--text); background: var(--glass-3); }
.ns-btn .ic { width: 13px; height: 13px; }
.ns-track { position: relative; flex: 1; height: 16px; border-radius: 4px; overflow: hidden; cursor: grab; touch-action: none; background: #111; }
.ns-track canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.ns-win { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; border: 1.5px solid #c99bff; background: rgba(155,61,245,.22); box-shadow: 0 0 12px rgba(155,61,245,.5); pointer-events: none; }
.navstrip:focus-visible { box-shadow: inset 0 0 0 2px rgba(180,108,255,.75); }
.kb-scroll { position: relative; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
.kb-scroll::-webkit-scrollbar { display: none; }
.keyboard { position: relative; margin: 0; user-select: none; -webkit-user-select: none; touch-action: none; outline: none; background: #050506; }
.keyboard::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 18px; z-index: 3; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.55), transparent); }
.rail { position: absolute; left: 0; right: 0; top: 0; height: 4px; z-index: 4; background: linear-gradient(90deg, #6a24c4, #a03a98 55%, #c0524a); box-shadow: 0 1px 10px rgba(155,61,245,.55); opacity: .9; pointer-events: none; }
.k { position: absolute; top: 0; cursor: pointer; touch-action: none; }
.k.w { z-index: 1; border-radius: 0 0 5px 5px; border-left: 1px solid rgba(0,0,0,.28); border-right: 1px solid rgba(255,255,255,.4);
  background: linear-gradient(180deg, #cfcbd6 0%, #f3f1f6 7%, #fdfcff 55%, #f4f2f7 88%, #e3dfe9 100%);
  box-shadow: inset 0 -7px 0 -1px #dcd8e2, inset 0 -8px 0 #c3bdcc, inset 0 1px 0 rgba(255,255,255,.7), 0 3px 4px rgba(0,0,0,.45);
  transition: background .06s, box-shadow .06s; }
.k.b { z-index: 2; border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, #050506 0%, #1f1e25 10%, #16151b 72%, #33313b 88%, #0f0e12 100%);
  box-shadow: inset 0 -7px 0 -2px #2e2c35, inset 1px 0 0 rgba(255,255,255,.07), inset -1px 0 0 rgba(0,0,0,.6), 0 4px 5px rgba(0,0,0,.65), 1px 2px 2px rgba(0,0,0,.4);
  transition: background .06s, box-shadow .06s; }
.k.b::before { content: ''; position: absolute; left: 18%; right: 18%; top: 6%; height: 55%; border-radius: 2px; background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0)); pointer-events: none; }
.k { --hc: #b46cff; --hc2: #c84fb4; }
.k[data-kind="play"] { --hc: #d46ad0; --hc2: #ea6a5a; }
.k[data-kind="L"] { --hc: #a35cff; --hc2: #7f3cf0; }
.k[data-kind="R"] { --hc: #f08a6e; --hc2: #ea6a5a; }
.k.w.on { background: linear-gradient(180deg, #c6bcd6 0%, #ebe3f6 9%, #f3ecfd 55%, color-mix(in srgb, var(--hc) 22%, #f5effc) 100%);
  box-shadow: inset 0 -3px 0 -1px #d6cce4, inset 0 -4px 0 #b9aed0, inset 0 0 22px color-mix(in srgb, var(--hc) 45%, transparent), 0 1px 2px rgba(0,0,0,.4); }
.k.b.on { background: linear-gradient(180deg, #050506 0%, #2a2235 12%, color-mix(in srgb, var(--hc) 38%, #1a1720) 80%, color-mix(in srgb, var(--hc) 50%, #251f2c) 100%);
  box-shadow: inset 0 -3px 0 -1px color-mix(in srgb, var(--hc) 60%, #2e2c35), 0 0 16px color-mix(in srgb, var(--hc) 70%, transparent), 0 2px 3px rgba(0,0,0,.6); }
.k.on::after { content: ''; position: absolute; left: 3px; right: 3px; bottom: 8px; height: 26%; border-radius: 4px; background: linear-gradient(0deg, color-mix(in srgb, var(--hc) 55%, transparent), transparent); pointer-events: none; }
.k.b.on::after { bottom: 6px; height: 34%; background: linear-gradient(0deg, color-mix(in srgb, var(--hc) 70%, transparent), transparent); }
.k.tgt { animation: tgt 1s ease-in-out infinite; }
.k.tgt[data-hand="L"] { --tc: #a35cff; } .k.tgt[data-hand="R"] { --tc: #f08a6e; }
.k.w.tgt { box-shadow: inset 0 0 0 2px var(--tc), inset 0 -40px 30px -20px color-mix(in srgb, var(--tc) 40%, transparent), 0 3px 4px rgba(0,0,0,.45); }
.k.b.tgt { box-shadow: inset 0 0 0 2px var(--tc), 0 0 14px var(--tc), 0 4px 5px rgba(0,0,0,.65); }
@keyframes tgt { 50% { filter: brightness(1.12); } }
.k.wrong { animation: wrong .4s ease-out; }
@keyframes wrong { 0% { box-shadow: inset 0 0 0 2px var(--bad), inset 0 0 30px rgba(239,91,98,.6); } 100% { } }
.kb-lbl { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font: 500 10.5px/1 var(--f-ui); color: #8b8596; pointer-events: none; }
.k.c .kb-lbl { color: #7a3fd0; font-weight: 600; }
.k.b .kb-lbl { color: #b6aec2; bottom: 10px; }
.kb-bind { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); font: 600 10px/1 var(--f-data); color: #8a46e0; padding: 3px 5px; border-radius: 4px; border: 1px solid rgba(155,61,245,.35); background: rgba(155,61,245,.07); pointer-events: none; }
.k.b .kb-bind { bottom: 12px; color: #dcc3ff; border-color: rgba(220,195,255,.35); background: rgba(155,61,245,.18); }
.k.b .kb-bind ~ .kb-lbl { display: none; }
.kb-dot { display: none; position: absolute; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; pointer-events: none; }
.k.w .kb-dot { top: 66%; }
.k.b .kb-dot { top: 52%; }
.k.sc .kb-dot { display: block; background: rgba(155,61,245,.75); box-shadow: 0 0 6px rgba(155,61,245,.6); }
.k.sc-root .kb-dot { width: 9px; height: 9px; background: var(--coral); box-shadow: 0 0 8px rgba(234,106,90,.8); }
.k.w.sc:not(.on) { background: linear-gradient(180deg, #cfcbd6 0%, #f1eef7 7%, #fbf8ff 55%, #f1ebfa 88%, #e1d9ec 100%); }
.keyboard.small .kb-lbl { font-size: 9px; bottom: 9px; }
.keyboard.small .kb-bind { font-size: 9px; padding: 2px 3px; bottom: 24px; }
.keyboard.small .k.b .kb-bind { bottom: 8px; }
.keyboard.tiny .kb-bind { display: none !important; }
.keyboard.tiny .k:not(.c) .kb-lbl { display: none; }
.keyboard.tiny .kb-lbl { font-size: 8px; }

/* ---------- panels ---------- */
.panel { position: fixed; right: 0; top: var(--toph); bottom: var(--kbw); width: min(390px, 100vw); z-index: 40; display: flex; flex-direction: column; background: rgba(15,15,20,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-left: 1px solid var(--line-2); box-shadow: -20px 0 60px -20px rgba(0,0,0,.8); transform: translateX(16px); opacity: 0; transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .18s; }
.panel.open { transform: none; opacity: 1; }
.panel[hidden] { display: none; }
.p-hd { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.p-hd h2 { margin: 0; font: 600 16px/1.2 var(--f-ui); }
.p-body { padding: 14px 18px 22px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.p-sec { font: 600 11px/1 var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 20px 0 10px; }
.p-sec:first-child { margin-top: 4px; }
.p-note { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.p-note.small { font-size: 12px; color: var(--muted); }
.field { margin: 0 0 14px; }
.f-lbl { display: flex; justify-content: space-between; font: 500 12.5px var(--f-ui); color: var(--text-2); margin-bottom: 6px; }
.f-lbl output { color: var(--muted); font: 500 12px var(--f-data); }
.check { display: flex; align-items: center; gap: 9px; font: 400 13px var(--f-data); color: var(--text-2); margin: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--violet); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--line-2); background: var(--glass); color: var(--text-2); font: 500 12px var(--f-ui); cursor: pointer; }
.chip:hover { border-color: rgba(155,61,245,.5); color: var(--text); }
.inst-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.inst-grid button { position: relative; text-align: left; padding: 10px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: border-color .15s, background .15s; }
.inst-grid button b { font: 500 13px/1.2 var(--f-ui); }
.inst-grid button span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.inst-grid button kbd { position: absolute; right: 7px; top: 7px; font-size: 10px; min-width: 16px; padding: 0 4px; opacity: .6; }
.inst-grid button:hover { border-color: var(--line-3); background: var(--glass-2); }
.inst-grid button.on { border-color: rgba(155,61,245,.6); background: linear-gradient(140deg, rgba(155,61,245,.18), rgba(234,106,90,.08)); box-shadow: inset 0 0 0 1px rgba(155,61,245,.25); }
.legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .lg-l { background: var(--hl); } .legend .lg-r { background: var(--hr); margin-left: 10px; }
.songs, .takes, .midi-devs { list-style: none; margin: 0; padding: 0; }
.songs li + li { margin-top: 8px; }
.song { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 10px; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; transition: border-color .15s, background .15s; }
.song:hover { border-color: rgba(155,61,245,.5); background: rgba(155,61,245,.08); }
.song .s-t { font: 500 14px/1.25 var(--f-ui); }
.song .s-c { font-size: 12px; color: var(--text-2); }
.song .s-l { font-size: 11.5px; color: var(--muted); }
.song .ic { grid-column: 2; grid-row: 1 / 4; align-self: center; width: 30px; height: 30px; padding: 7px; border-radius: 50%; background: var(--grad); color: #fff; }
.take-actions { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.take-actions .btn { flex: 1; }
.takes { margin-top: 10px; }
.take { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 6px 10px; padding: 10px; border-radius: 11px; border: 1px solid var(--line); background: var(--glass); margin-bottom: 8px; }
.take.playing { border-color: rgba(200,79,180,.6); box-shadow: inset 0 0 0 1px rgba(200,79,180,.2); background: rgba(200,79,180,.07); }
.tk-play { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; cursor: pointer; align-self: center; box-shadow: 0 4px 14px -4px rgba(155,61,245,.7); }
.tk-play .ic { width: 16px; height: 16px; }
.tk-meta { min-width: 0; display: flex; flex-direction: column; }
.tk-name { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 5px; margin-left: -6px; font: 500 14px var(--f-ui); color: var(--text); outline: none; }
.tk-name:hover { border-color: var(--line); }
.tk-name:focus { border-color: rgba(155,61,245,.6); background: rgba(0,0,0,.25); }
.tk-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-act { display: flex; gap: 4px; align-items: center; grid-column: 2; }
.mini { height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text-2); font: 600 11px var(--f-ui); letter-spacing: .04em; cursor: pointer; display: inline-flex; align-items: center; }
.mini:hover { border-color: rgba(155,61,245,.6); color: #fff; }
.tk-act .icon-btn:first-of-type { margin-left: auto; }
.tk-act .del.confirm { background: rgba(239,91,98,.2); color: #ff8d92; border-color: rgba(239,91,98,.5); }
.takes .empty { color: var(--muted); font-size: 13px; padding: 20px 6px; text-align: center; border: 1px dashed var(--line-2); border-radius: 11px; }
.midi-devs li { font-size: 12.5px; padding: 6px 10px; border-radius: 8px; background: var(--glass-2); margin-top: 6px; color: var(--text-2); }
.midi-devs li::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 8px; }

/* ---------- help modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(5,5,8,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-card { width: min(760px, 100%); max-height: 100%; overflow-y: auto; background: #121218; border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.9); }
.modal-card .p-hd h2 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 18px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 26px; padding: 6px 20px 0; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--text-2); font-size: 13px; }
.modal-card > .p-note { padding: 14px 20px 0; color: var(--muted); font-size: 12.5px; }
.help-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 6px 20px 18px; flex-wrap: wrap; }

/* ---------- start overlay ---------- */
.start { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; overflow: hidden;
  background: radial-gradient(800px 460px at 50% 30%, rgba(155,61,245,.22), transparent 65%), radial-gradient(700px 380px at 75% 90%, rgba(234,106,90,.14), transparent 65%), rgba(8,8,10,.88);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .45s ease, visibility .45s; }
.start.gone { opacity: 0; visibility: hidden; }
.start[hidden] { display: none; }
.start-card { position: relative; z-index: 2; text-align: center; max-width: 520px; }
.start-logo { height: 34px; width: auto; opacity: .95; }
.start h1 { font: 600 clamp(38px, 7vw, 64px)/1.05 var(--f-ui); letter-spacing: -.025em; margin: 18px 0 12px; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.start-sub { color: var(--text-2); font: 300 clamp(14px, 1.8vw, 17px)/1.55 var(--f-ui); margin: 0 auto 26px; max-width: 440px; }
.start-tip { color: var(--muted); font-size: 12.5px; margin: 18px 0 0; }
.start-keys { position: absolute; left: 50%; bottom: -30px; transform: translateX(-50%) perspective(700px) rotateX(48deg); width: min(1100px, 140vw); height: 200px; display: flex; gap: 3px; opacity: .55; mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); }
.start-keys i { flex: 1; border-radius: 0 0 6px 6px; background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.14)); border: 1px solid rgba(255,255,255,.08); }
.start-keys i:nth-child(7n+3) { background: linear-gradient(180deg, rgba(155,61,245,.05), rgba(155,61,245,.45)); box-shadow: 0 0 30px rgba(155,61,245,.4); }
.start-keys i:nth-child(11n+5) { background: linear-gradient(180deg, rgba(234,106,90,.05), rgba(234,106,90,.4)); box-shadow: 0 0 30px rgba(234,106,90,.35); }

/* ---------- toasts, preparing ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--kbw) + 14px); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 9px 15px; border-radius: 10px; background: rgba(28,28,36,.96); border: 1px solid var(--line-2); box-shadow: 0 10px 30px -10px rgba(0,0,0,.8); font: 500 13px var(--f-ui); color: var(--text); animation: tin .2s ease-out; white-space: nowrap; }
.toast.bad { border-color: rgba(239,91,98,.5); color: #ffb0b4; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.preparing { position: fixed; left: 16px; bottom: calc(var(--kbw) + 14px); z-index: 30; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 20px; background: rgba(18,18,24,.85); border: 1px solid var(--line); font: 500 11.5px var(--f-ui); color: var(--muted); transition: opacity .5s; }
.preparing i { width: 70px; height: 3px; border-radius: 3px; background: var(--glass-3); overflow: hidden; }
.preparing b { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.preparing.done { opacity: 0; }
.preparing[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1720px) { .q-labels { display: none !important; } }
@media (max-width: 1500px) { .controls { gap: 10px; } .rng { width: 66px; } }
@media (max-width: 1360px) { .ctl.scale, .vsep.q-scale-sep { display: none; } }
@media (max-width: 1280px) { .navbtn span:not(.sr) { display: none; } .navbtn { padding: 0 9px; } }
@media (max-width: 1100px) { .meter { display: none; } .appname { display: none; } .controls { gap: 8px; } .rng { width: 58px; } }
@media (max-width: 900px) { .hide-s { display: none !important; } .sel-inst { min-width: 0; width: 140px; } .topbar { gap: 7px; } .hire { font-size: 11px; } }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand { order: 1; } .grow { order: 2; } .midi-ind, .nav { order: 3; }
  .brk { display: block; order: 4; flex-basis: 100%; height: 0; }
  .sel-inst { order: 5; flex: 1; width: auto; } .sep { display: none; } .transport, .metro { order: 6; }
  .readout { left: 10px; top: 10px; padding: 8px 12px; min-width: 0; }
  .ro-name { font-size: 19px; }
  .hire { left: 10px; right: auto; bottom: 10px; }
  .help-grid { grid-template-columns: 1fr; }
  .panel { width: 100vw; }
}
@media (max-width: 440px) { .beats { display: none; } .clock { min-width: 0; font-size: 12px; padding: 0; } .num { width: 50px; } .sel-inst { min-width: 112px; } .topbar { gap: 6px; } }
@media (max-height: 520px) {
  .topbar { min-height: 46px; padding-top: 5px; padding-bottom: 5px; }
  .tbtn, .icon-btn, .navbtn { height: 32px; } .tbtn { width: 32px; }
  .brand img { height: 22px; }
  .controls { min-height: 38px; padding-top: 3px; padding-bottom: 3px; gap: 10px; }
  .readout { top: 8px; left: 10px; padding: 6px 11px; }
  .ro-name { font-size: 17px; } .ro-detail { font-size: 11px; }
  .hire { bottom: 8px; padding: 5px 9px; font-size: 10.5px; }
  .idle { font-size: 12.5px; }
  .panel { bottom: 0; top: var(--toph); }
  .learn-hud { top: 8px; padding: 8px 11px; width: min(460px, calc(100% - 20px)); }
  .lh-actions { position: absolute; right: 10px; top: 8px; margin: 0; } .lh-actions .btn { height: 26px; padding: 0 8px; } .lh-top { padding-right: 160px; } .lh-mode { display: none; }
  body.learning .readout { display: none; }
  .count { font-size: 64px; }
  .navstrip { height: 20px; padding-top: 2px; padding-bottom: 2px; } .ns-track { height: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; } }
.rng.rng--full { width: 100%; }
