:root { --hue: 5; --bg: #0c0e13; --panel: #151821; --line: #262b38; --text: #e8eaf0; --dim: #8b92a5; --accent: hsl(var(--hue) 85% 60%); }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: radial-gradient(1200px 700px at 50% 30%, hsl(var(--hue) 40% 12%), var(--bg) 70%); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif; overflow: hidden; user-select: none; display: flex; flex-direction: column; transition: background .4s; }
kbd { font: 600 11px "Segoe UI", sans-serif; background: #232836; border: 1px solid #343b4d; border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: #cfd4e2; white-space: nowrap; }
h2 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 0 0 8px; font-weight: 600; }
h2 small { float: right; letter-spacing: 0; }

header { display: flex; align-items: center; gap: 20px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #0f1218cc; flex: none; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo { width: 20px; height: 20px; border-radius: 4px; background:
  linear-gradient(var(--accent), var(--accent)) 0 0/9px 9px no-repeat, linear-gradient(#fff5, #fff5) 11px 0/9px 9px no-repeat,
  linear-gradient(#fff5, #fff5) 0 11px/9px 9px no-repeat, linear-gradient(var(--accent), var(--accent)) 11px 11px/9px 9px no-repeat; }
.now { flex: 1; display: flex; align-items: baseline; gap: 12px; min-width: 0; }
#kitName { font-size: 20px; font-weight: 700; color: var(--accent); white-space: nowrap; }
#kitTag { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp { font-size: 12px; color: var(--dim); padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px; white-space: nowrap; }
.gp.on { color: #7dffa8; border-color: #2c6b45; background: #12251a; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 214px 1fr 270px; }
aside { padding: 14px; overflow-y: auto; background: #10131acc; }
aside.kits { border-right: 1px solid var(--line); }
aside.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
aside::-webkit-scrollbar { width: 8px; } aside::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 4px; }

.kit { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 1px solid transparent; color: var(--text);
  padding: 5px 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.kit i { width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--h) 85% 60%); flex: none; }
.kit b { font-weight: 600; display: block; line-height: 1.2; }
.kit small { color: var(--dim); font-size: 11px; display: block; line-height: 1.2; }
.kit:hover { background: #1b1f2b; }
.kit.sel { background: hsl(var(--h) 50% 16%); border-color: hsl(var(--h) 70% 45%); }

.stage { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 16px; }
.grid { --s: min(calc(100vh - 86px), calc(100vw - 520px)); width: var(--s); height: var(--s); display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: clamp(6px, 1.2vmin, 12px); }
.pad { --ph: 210; position: relative; border-radius: 12px; border: 1px solid hsl(var(--ph) 45% 32%); cursor: pointer; overflow: hidden; touch-action: none;
  background: linear-gradient(160deg, hsl(var(--ph) 42% 22%), hsl(var(--ph) 48% 12%)); box-shadow: inset 0 1px 0 #ffffff14, 0 4px 14px #0008;
  display: flex; align-items: center; justify-content: center; padding: 6px; }
.pad .nm { font-weight: 700; font-size: clamp(11px, 1.9vmin, 17px); text-align: center; line-height: 1.15; text-shadow: 0 1px 3px #000a; pointer-events: none; }
.pad .k { position: absolute; font-weight: 700; color: #ffffffc8; pointer-events: none; font-size: clamp(9px, 1.35vmin, 12px); }
.pad .k1 { top: 6px; left: 8px; font-size: clamp(11px, 1.9vmin, 17px); }
.pad .k1 em { font-style: normal; opacity: .45; margin-left: 5px; font-size: .8em; }
.pad .k2 { top: 7px; right: 8px; opacity: .6; }
.pad .k3 { bottom: 6px; right: 8px; opacity: .6; }
.pad .fl { position: absolute; inset: 0; background: radial-gradient(circle, #fff, hsl(var(--ph) 100% 65%) 60%); opacity: 0; pointer-events: none; }
.pad[data-c=kick] { --ph: 4; } .pad[data-c=snare] { --ph: 34; } .pad[data-c=hat] { --ph: 190; }
.pad[data-c=cym] { --ph: 52; } .pad[data-c=tom] { --ph: 135; } .pad[data-c=fx] { --ph: 275; }

button.big { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid hsl(var(--hue) 70% 45%);
  background: hsl(var(--hue) 55% 22%); color: var(--text); font: 600 14px "Segoe UI", sans-serif; cursor: pointer; }
button.big .lbl { flex: 1; text-align: left; }
button.big .ico { width: 18px; text-align: center; }
button.big.alt { background: #1b1f2b; border-color: var(--line); }
button.big.on { background: var(--accent); color: #0c0e13; border-color: var(--accent); }
button.big.on kbd { background: #0003; border-color: #0004; color: #0c0e13; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row label { color: var(--dim); }
.row input[type=range] { width: 150px; accent-color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); font-size: 16px; cursor: pointer; }
.stepper span { width: 46px; text-align: center; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.stage { position: relative; }
#count { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; pointer-events: none;
  font: 800 min(38vh, 300px)/1 "Segoe UI", sans-serif; color: #fff; text-shadow: 0 0 60px #ff3b3b, 0 6px 30px #000; }
#count.show { display: flex; }
body.rec .grid { outline: 3px solid #ff4a4a; outline-offset: 8px; border-radius: 14px; }
.recorder, .sect { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.recorder h2, .sect h2 { margin: 0; }
button.big.recb { background: #3a1518; border-color: #a13a3a; }
button.big.recb .ico { color: #ff5a5a; }
button.big.recb.on { background: #ff4a4a; border-color: #ff4a4a; color: #fff; animation: pulse 1s infinite; }
button.big.recb.on .ico { color: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #ff4a4a44; } }
button:disabled { opacity: .4; cursor: default; }
.bar { height: 6px; border-radius: 3px; background: #232836; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
body.rec .bar i { background: #ff4a4a; }
#loopInfo { min-height: 2.6em; }
.note { font-size: 12px; color: var(--dim); }
.seg { display: flex; gap: 4px; }
.seg button, .row3 button { border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 7px; cursor: pointer; font: inherit; font-size: 12.5px; padding: 5px 0; }
.seg button { width: 30px; font-weight: 700; }
.seg button.sel { background: var(--accent); border-color: var(--accent); color: #0c0e13; opacity: 1; }
.row3 { display: grid; grid-template-columns: 1.5fr 1fr 1.2fr; gap: 6px; }
.row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
#swapHint { color: #1a1300; background: #ffc83d; font-weight: 700; font-size: 12.5px; padding: 3px 12px; border-radius: 20px; white-space: nowrap; }
#swapHint:empty { display: none; }
body.swap #kitTag { display: none; }
body.swap .pad { outline: 2px dashed #ffc83d99; outline-offset: -5px; }
body.swap .pad.pick { outline: 4px solid #ffc83d; box-shadow: 0 0 26px #ffc83daa; animation: pick .7s infinite alternate; }
@keyframes pick { to { transform: scale(.94); } }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
button.small { border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 10px; cursor: pointer; font: inherit; font-size: 12.5px; padding: 4px 12px; }
button.big.alt.on { background: #ffc83d; border-color: #ffc83d; }
#btnMetro.on, #btnLoop.on { background: var(--accent); border-color: var(--accent); }
.help { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 12px; color: #b9bfce; font-size: 12.5px; }
.help p { margin: 0 0 8px; } .help b { color: var(--text); }
.help .tip { background: hsl(var(--hue) 45% 15%); border: 1px solid hsl(var(--hue) 50% 30%); border-radius: 8px; padding: 8px 10px; }

/* ---- expert mode ---- */
body:not(.expert) .x { display: none !important; }
[hidden] { display: none !important; }
.pill { display: flex; align-items: center; gap: 8px; font: 600 12px "Segoe UI", sans-serif; color: var(--dim); background: #1b1f2b; border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.pill.on { color: #0c0e13; background: var(--accent); border-color: var(--accent); }
.pill.on kbd { background: #0003; border-color: #0004; color: #0c0e13; }
.stepper button.wide { width: auto; padding: 0 8px; font-size: 12.5px; margin-right: 4px; }
.row2.even { grid-template-columns: 1fr 1fr; }
.row2 .seg { align-items: center; }
.row2 .seg button { width: 36px; padding: 8px 0; }
.sect .big { padding: 9px 12px; }
#midiStatus.on { color: #7dffa8; }
#layerChips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; border: 1px solid hsl(var(--hue) 70% 45%); border-radius: 14px; overflow: hidden; background: hsl(var(--hue) 55% 22%); }
.chip button { border: 0; background: none; color: var(--text); font: 600 12px "Segoe UI", sans-serif; padding: 3px 8px; cursor: pointer; }
.chip .x, .beat .x { display: inline-block !important; padding: 3px 7px; color: var(--dim); border-left: 1px solid #fff2; }
.chip.muted { background: #1b1f2b; border-color: var(--line); }
.chip.muted button:first-child { text-decoration: line-through; color: var(--dim); }
.beats { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
#beatName, #edKit { min-width: 0; width: 100%; background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12.5px; }
#edKit { width: 150px; }
#beatList { display: flex; flex-direction: column; gap: 4px; max-height: 130px; overflow-y: auto; }
.beat { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #1b1f2b; }
.beat button { border: 0; background: none; color: var(--text); font: inherit; font-size: 12.5px; padding: 5px 8px; cursor: pointer; text-align: left; }
.beat button:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.beat button:hover { background: #262b38; }
#editor { display: flex; flex-direction: column; gap: 8px; border: 1px solid #ffc83d88; border-radius: 10px; padding: 9px; background: #1a170c; }
.edhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#edSounds { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#edSounds button { border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 6px; font: inherit; font-size: 11.5px; padding: 4px 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#edSounds button.sel { background: #ffc83d; border-color: #ffc83d; color: #1a1300; font-weight: 700; }
.pad .k4 { bottom: 6px; left: 8px; color: #ffd66b; }
.pad .ring { position: absolute; inset: 3px; border: 4px solid #fff; border-radius: 10px; opacity: 0; pointer-events: none; }
#btnLearn.on, #btnRepeat.on, #btnBass.on, #btnChords.on, #btnStage.on { background: var(--accent); border-color: var(--accent); }
/* stage view: just the pads, with a visualiser behind */
#viz { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
header, main { position: relative; z-index: 1; }
#stageBar { display: none; position: fixed; top: 10px; left: 14px; right: 14px; z-index: 3; justify-content: space-between; align-items: center; pointer-events: none; }
#stageKit { font-size: 20px; font-weight: 700; color: var(--accent); text-shadow: 0 2px 8px #000; }
#stageExit { pointer-events: auto; font: 600 12px "Segoe UI", sans-serif; color: var(--text); background: #1b1f2bcc; border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; cursor: pointer; }
body.stage header, body.stage aside { display: none; }
body.stage #stageBar { display: flex; }
body.stage main { grid-template-columns: 1fr; }
body.stage .grid { --s: min(calc(100vh - 70px), calc(100vw - 40px)); margin-top: 30px; }

/* ---- grooves, sharing ---- */
.mo, #mbar { display: none; }
.row.grooves .seg button { width: 30px; }
#grooveName { margin-top: -6px; text-align: right; }
.row3.two { grid-template-columns: 1fr 1fr; }
#btnShare:not(:disabled) { border-color: hsl(var(--hue) 70% 45%); }
#shareBox { display: flex; flex-wrap: wrap; gap: 6px; }
#shareUrl { flex: 1; min-width: 0; background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12px; }
#shared { position: fixed; inset: 0; z-index: 20; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; }
#shared .card { background: var(--panel); border: 1px solid hsl(var(--hue) 70% 45%); border-radius: 14px; padding: 18px; max-width: 380px; width: 100%; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 12px 40px #000c; }
#shared .card b { font-size: 16px; }
#sharedInfo { color: var(--accent); font-weight: 600; }
#shared .btns { display: flex; gap: 8px; }
#shared .btns .big { flex: 1; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: #1b1f2b; border: 1px solid var(--accent); color: var(--text); padding: 9px 16px; border-radius: 20px; font-weight: 600; box-shadow: 0 6px 20px #0008; max-width: calc(100vw - 32px); text-align: center; }

/* ---- Keys mode ---- */
.stage { flex-direction: column; gap: 12px; }
body.keys .grid { --s: min(calc(100vh - 86px - 196px), calc(100vw - 520px)); }
@media (min-width: 901px) { body.keys:has(#chordRow:not([hidden])) .grid { --s: min(calc(100vh - 86px - 240px), calc(100vw - 520px)); } }
body.keys .pad .k1 { display: none; }
#keysPanel { width: min(100%, 960px); display: flex; flex-direction: column; gap: 8px; flex: none; }
.kbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kbar button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); font-size: 16px; cursor: pointer; }
#instSel { background: #0e1118; color: var(--text); border: 1px solid hsl(var(--hue) 70% 45%); border-radius: 8px; padding: 5px 8px; font: 600 14px "Segoe UI", sans-serif; min-width: 0; max-width: 220px; }
.kbar .oct { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
#octLbl { font-weight: 700; min-width: 70px; text-align: center; }
#susLbl.on { color: #0c0e13; background: #ffc83d; border-radius: 12px; padding: 1px 8px; font-weight: 700; }
#instLoad { color: #ffc83d; }
#piano { position: relative; height: 150px; touch-action: none; user-select: none; }
.pk { position: absolute; top: 0; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px; font: 700 11px "Segoe UI", sans-serif; }
.pk.wht { height: 100%; background: linear-gradient(#f4f5f8, #d9dce4); border: 1px solid #5a6070; border-radius: 0 0 7px 7px; color: #59607a; z-index: 1; }
.pk.blk { height: 60%; background: linear-gradient(#2a2f3c, #0d0f15); border: 1px solid #000; border-radius: 0 0 5px 5px; color: #9aa3ba; z-index: 2; padding-bottom: 4px; }
.pk em { font-style: normal; font-size: 9px; opacity: .55; margin-top: 2px; }
.pk.on.wht { background: linear-gradient(hsl(var(--hue) 90% 75%), hsl(var(--hue) 85% 58%)); color: #1a1300; }
.pk.on.blk { background: linear-gradient(hsl(var(--hue) 90% 62%), hsl(var(--hue) 80% 40%)); color: #fff; }
.micbar i { background: #4dff88; }
#btnMic.on { background: #ff4a4a; border-color: #ff4a4a; color: #fff; }
#btnKeys.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; }
#btnKeys.on kbd { background: #0003; border-color: #0004; color: #0c0e13; }

/* ---- In key, chords, arp, layer rows ---- */
#scaleSel, #arpMode { background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; font: 600 13px "Segoe UI", sans-serif; }
#keyLbl { color: var(--accent); font-weight: 700; }
.kbar button.kt { width: auto; padding: 0 12px; font: 700 13px "Segoe UI", sans-serif; }
.kbar button.kt.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; }
.kbar .seg button { width: 40px; font-size: 12px; }
body:not(.arp) #arpRate, body:not(.arp) #arpMode { display: none; }
#chordRow { display: flex; gap: 6px; flex-wrap: wrap; }
#chordRow[hidden] { display: none; }
.chd { flex: 1; min-width: 56px; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 9px; padding: 7px 6px; font: 700 14px "Segoe UI", sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; touch-action: none; }
.chd kbd { font-size: 10px; }
.chd.prog { border-color: hsl(var(--hue) 70% 45%); }
.chd.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; }
.pk.out.wht { background: linear-gradient(#9da2ad, #7d828e); }
.pk.out.blk { background: linear-gradient(#1a1d24, #0a0b0e); opacity: .6; }
#layerChips { display: flex; flex-direction: column; gap: 4px; }
.lrow { display: flex; align-items: center; gap: 6px; border: 1px solid hsl(var(--hue) 50% 35%); background: hsl(var(--hue) 40% 15%); border-radius: 9px; padding: 3px 4px 3px 2px; }
.lrow.muted { background: #1b1f2b; border-color: var(--line); }
.lrow.muted .lname { text-decoration: line-through; color: var(--dim); }
.lname { flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: var(--text); font: 600 12.5px "Segoe UI", sans-serif; padding: 3px 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvol { width: 70px; accent-color: var(--accent); }
.lfx { background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 6px; font-size: 11.5px; padding: 2px; max-width: 86px; }
.lrow .x { border: 0; background: none; color: var(--dim); font-size: 15px; cursor: pointer; padding: 0 5px; }

/* ---- live effects, pitch, song, sampling ---- */
#pitchLbl { color: var(--text); font-variant-numeric: tabular-nums; }
.sect h2 .reset { float: right; border: 1px solid #ffc83d88; background: #2a2410; color: #ffd66b; border-radius: 8px; font: 700 11.5px "Segoe UI", sans-serif; padding: 2px 8px; cursor: pointer; letter-spacing: 0; text-transform: none; }
.sect h2 .reset kbd { font-size: 9px; padding: 0 3px; }
.fxgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fx { border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 10px; padding: 12px 6px; font: 700 13px "Segoe UI", sans-serif; cursor: pointer; touch-action: none; user-select: none; }
.fx.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; box-shadow: 0 0 18px hsl(var(--hue) 90% 55% / .6); }
.song { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.secs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.secs button { position: relative; border: 1px solid var(--line); background: #1b1f2b; color: var(--dim); border-radius: 10px; padding: 9px 0; font: 800 16px "Segoe UI", sans-serif; cursor: pointer; }
.secs button.has { color: var(--text); }
.secs button.has::after { content: ''; position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.secs button.sel { background: hsl(var(--hue) 55% 22%); border-color: hsl(var(--hue) 70% 50%); color: var(--text); }
.secs button.pend { animation: pend .5s infinite alternate; }
@keyframes pend { to { background: hsl(var(--hue) 60% 35%); border-color: var(--accent); } }
#songOrder { min-width: 0; width: 100%; background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: 700 13px "Segoe UI", sans-serif; letter-spacing: .15em; }
#btnSong.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; }
#btnSampleMic.on { background: #ff4a4a; border-color: #ff4a4a; color: #fff; }
body.sampling .grid { outline: 3px dashed #ff4a4a; outline-offset: 8px; border-radius: 14px; }
#useSamplesRow[hidden] { display: none; }

/* ---- phone and small-tablet layout: pads fill the screen, controls in a bottom bar, panels open as sheets ---- */
@media (max-width: 900px) {
  body { touch-action: manipulation; height: 100dvh; }
  header { gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; }
  .brand { font-size: 0; gap: 0; }
  .gp, #kitTag, header .pill kbd { display: none; }
  .now { gap: 6px; justify-content: center; flex-wrap: wrap; }
  #kitName { font-size: 18px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: calc(100vw - 230px); text-decoration: underline dotted #fff5; text-underline-offset: 4px; }
  #swapHint { order: 5; flex-basis: 100%; text-align: center; white-space: normal; }
  .mo { display: inline-flex; }
  #kitPrev, #kitNext { width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); font-size: 20px; flex: none; cursor: pointer; }
  main { grid-template-columns: 1fr; }
  aside.kits, aside.side { display: none; }
  body.sheet-kits aside.kits, body.sheet-side aside.side { display: flex; flex-direction: column; gap: 10px; position: fixed; inset: 0; z-index: 15; background: var(--bg);
    border: 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); padding-top: max(12px, env(safe-area-inset-top)); overflow-y: auto; }
  body.sheet-kits aside.kits { gap: 2px; }
  .sheetClose { align-self: flex-end; position: sticky; top: 0; z-index: 2; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); border-radius: 20px; padding: 8px 16px; font: 600 13px "Segoe UI", sans-serif; cursor: pointer; flex: none; }
  .kit { padding: 9px 8px; }
  .stage { padding: 10px; }
  .grid { --s: min(calc(100vw - 20px), calc(100dvh - 150px)); gap: 7px; }
  @media (orientation: portrait) { .grid { width: 100%; height: min(100%, calc((100vw - 20px) * 1.45)); } }
  .pad { border-radius: 10px; }
  .pad .k1, .pad .k2, .pad .k3 { display: none; }
  .pad .nm { font-size: clamp(11px, 3.7vw, 17px); }
  #mbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0f1218ee; position: relative; z-index: 2; flex: none; }
  #mbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border-radius: 10px; border: 1px solid var(--line); background: #1b1f2b; color: var(--text); font: 600 11px "Segoe UI", sans-serif; min-width: 0; cursor: pointer; }
  #mbar button i { font-style: normal; font-size: 16px; line-height: 1.1; }
  #mbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #mbar button.on { background: var(--accent); border-color: var(--accent); color: #0c0e13; }
  #mbar button.rec i { color: #ff5a5a; }
  #mbar button.rec.on { background: #ff4a4a; border-color: #ff4a4a; color: #fff; }
  #mbar button.rec.on i { color: #fff; }
  #mbar button:disabled { opacity: .4; }
  body.stage #mbar { display: none; }
  body.stage .grid { --s: min(calc(100vw - 20px), calc(100dvh - 60px)); }
  body.rec .grid { outline-offset: 4px; }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.keys .stage { gap: 8px; }
  body.keys .grid { --s: min(calc(100vw - 20px), calc(100dvh - 150px - 230px)); width: var(--s); height: var(--s); flex: none; }
  .chd { padding: 6px 4px; font-size: 13px; min-width: 44px; } .chd kbd { display: none; }
  #keyLbl { font-size: 11px; }
  body.keys #piano { height: 120px; }
  #instSel { max-width: 150px; font-size: 13px; }
  .kbar .oct { margin-left: 0; }
  #susLbl { display: none; }
  body.keys #swapHint, .pk span { display: none; }
}
@media (max-width: 900px) and (max-height: 520px) {
  header { padding-top: 4px; padding-bottom: 4px; }
  .grid { --s: min(calc(100vw - 20px), calc(100dvh - 118px)); height: 100%; width: min(100%, calc((100dvh - 118px) * 1.9)); }
  #mbar button { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 2px; }
}

/* My Drums: black grids for your own kits */
.kithead { color: var(--dim); font: 600 11px "Segoe UI", sans-serif; letter-spacing: .08em; text-transform: uppercase; margin: 12px 8px 4px; }
.kitrow { display: flex; align-items: center; gap: 2px; }
.kitrow .kit { flex: 1; min-width: 0; }
.kit.mine i { background: #000; border: 1px solid #8b92a5; }
.kit.mine.sel { background: #1a1d24; border-color: #5d6578; }
.ren { flex: none; width: 28px; height: 28px; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--dim); cursor: pointer; font-size: 14px; }
.ren:hover { background: #1b1f2b; color: var(--text); border-color: var(--line); }
.renin { flex: 1; min-width: 0; margin: 2px 0; padding: 6px 8px; border-radius: 8px; border: 1px solid #5d6578; background: #0a0b0e; color: var(--text); font: 600 14px "Segoe UI", sans-serif; }
body.mine { background: radial-gradient(1200px 700px at 50% 30%, #16181d, var(--bg) 70%); }
.pad[data-c=empty] { border-color: #2a2d35; background: linear-gradient(160deg, #0b0c0f, #030304); box-shadow: inset 0 1px 0 #ffffff0a, 0 4px 14px #0008; }
.pad[data-c=empty] .nm { color: #4d5361; font-weight: 600; }
.pad[data-c=empty] .fl { background: radial-gradient(circle, #ffffff55, #8b92a533 60%); }
#myFill { flex: 1; min-width: 0; background: #0e1118; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: 600 13px "Segoe UI", sans-serif; }
