/* MD|442 v2 — brushed-aluminium console. Shared by the desktop console (.md.desk) and the phone app (.md.phone). */
.md { --g: #3dff7a; --ink: #1a1a1a; --mut: #3a3a3a; --line: rgba(0,0,0,.24); --s: 38px;
  --panel: repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, rgba(0,0,0,.035) 1px 2px, rgba(255,255,255,.03) 2px 3px), linear-gradient(180deg, #e3e4e6 0%, #c9cbce 45%, #b4b6b9 100%);
  --keyb: linear-gradient(#f4f4f5, #cfd0d3); --keysh: inset 0 -2px 0 rgba(0,0,0,.22), 0 2px 3px rgba(0,0,0,.25);
  --dark: linear-gradient(#2a2a2a, #191919); --lit: linear-gradient(#5dff95, #22c95a); --glow: 0 0 0 2px var(--g), 0 0 14px rgba(61,255,122,.75);
  font-family: 'Martian Mono', ui-monospace, monospace; color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
.md, .md *, .md *::before, .md *::after { box-sizing: border-box; }
.md button { font: inherit; color: inherit; cursor: pointer; padding: 0; margin: 0; }
.md [hidden] { display: none !important; }
.md button:focus-visible, .md input:focus-visible { outline: 2px solid #0a8f3c; outline-offset: 2px; }
.md .cap { font-size: 9px; letter-spacing: .14em; color: var(--mut); text-transform: uppercase; white-space: nowrap; }

/* silver keys; .led keys carry a lamp */
.md .key { position: relative; min-height: 34px; padding: 4px 10px; background: var(--keyb); border: 1px solid #8d8f92; border-radius: 5px; box-shadow: var(--keysh); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; touch-action: manipulation; }
.md .key:active { transform: translateY(1px); }
.md .key:disabled { opacity: .38; cursor: default; }
.md .key.led { padding-top: 15px; }
.md .key.led::before { content: ''; position: absolute; left: 50%; top: 5px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; border: 1px solid #111; background: #0a0a0a; }
.md .key.led.on::before, .md .key.led.hit::before { background: var(--g); box-shadow: 0 0 6px var(--g), 0 0 12px rgba(61,255,122,.7); }
.md .key.on { font-weight: 600; }
.md .key.sel { box-shadow: var(--glow); border-color: #0a8f3c; font-weight: 600; }
.md .key.mute { color: #777; text-decoration: line-through; }
.md .key.pend { animation: mdblink .5s steps(2) infinite; }
@keyframes mdblink { 50% { box-shadow: var(--glow); } }
.md .key.big { min-width: 76px; min-height: 52px; border-color: #000; background: linear-gradient(#2c2c2c, #0e0e0e); color: #f2f2f2; font-size: 11px; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 3px 6px rgba(0,0,0,.4); }
.md .key.big.go.on { color: var(--g); text-shadow: 0 0 8px rgba(61,255,122,.8); }
.md .key.ico { display: grid; place-items: center; min-width: 52px; min-height: 52px; }
.md .key.sw { min-height: 22px; padding: 2px 6px; font-size: 8px; color: #666; }
.md .key.sw.on { color: var(--ink); background: linear-gradient(#d9ffe6, #a9ecc0); border-color: #0a8f3c; }
.md .key.x { min-height: 28px; min-width: 28px; padding: 0 6px; }
.md .seg { display: flex; gap: 4px; }
.md .seg .key { flex: 1; }
.md .seg .key.on { background: linear-gradient(#2c2c2c, #0e0e0e); color: var(--g); border-color: #000; }
.md .seg .key.led.on { background: var(--keyb); color: var(--ink); border-color: #8d8f92; }

/* knobs: label, knob, value in real units */
.md .kb { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; overflow: hidden; padding: 2px 0; }
.md .kl, .md .kv { font-size: 8px; letter-spacing: .04em; line-height: 1.1; white-space: nowrap; max-width: 100%; overflow: hidden; text-transform: uppercase; }
.md .kl { color: var(--mut); font-weight: 600; }
.md .knob { --arc: #1a1a1a; --trk: rgba(0,0,0,.2); position: relative; width: var(--s); height: var(--s); flex: none; border-radius: 50%; border: 0; background: none; touch-action: none; cursor: ns-resize; }
.md .knob .arc { position: absolute; inset: 0; border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%); }
.md .knob .cap { position: absolute; inset: 14%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fafafa, #c4c6c9 55%, #9c9ea1); box-shadow: 0 2px 4px rgba(0,0,0,.45), inset 0 -2px 2px rgba(0,0,0,.18); }
.md .knob .ptr { position: absolute; inset: 14%; border-radius: 50%; }
.md .knob .ptr::after { content: ''; position: absolute; left: 50%; top: 8%; width: 2px; height: 32%; margin-left: -1px; border-radius: 1px; background: #111; }
.md .kb.turn .kv { color: #0a6b2e; font-weight: 600; }
.md .kb.off .knob { opacity: .55; }

/* display */
.md .lcd { display: flex; align-items: center; gap: 12px; min-width: 0; text-align: left; background: #0c0d0d; border: 0; border-radius: 6px; padding: 8px 14px; box-shadow: inset 0 2px 8px rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.6); color: #f4f4f4; }
.md .lcd .lt2 { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.md .lcd .l1 { font-size: 14px; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 0 6px rgba(255,255,255,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md .lcd .l2 { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #bdbdbd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md .lcd .tp { font-family: 'Anybody', sans-serif; font-weight: 900; font-variation-settings: 'wdth' 130; font-size: 44px; line-height: 1; color: var(--g); text-shadow: 0 0 12px rgba(61,255,122,.55); font-variant-numeric: tabular-nums; }
.md .lcd .tl { font-size: 9px; letter-spacing: .14em; color: #bdbdbd; align-self: flex-end; padding-bottom: 6px; }
.md .logo { font-family: 'Anybody', sans-serif; font-weight: 900; font-variation-settings: 'wdth' 150; letter-spacing: -.03em; color: #111; white-space: nowrap; line-height: .9; }

/* steps */
.md .st { position: relative; min-width: 0; border-radius: 5px; border: 1px solid #000; background: var(--dark); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.35); color: #8a8a8a; touch-action: none; }
.md .st.alt { background: linear-gradient(#3a3a3a, #262626); color: #a8a8a8; }
.md .st.on { background: var(--lit); box-shadow: 0 0 10px rgba(61,255,122,.55), inset 0 1px 0 rgba(255,255,255,.45); color: #06310f; }
.md .st.out { opacity: .28; }
.md .st.ph { outline: 2px solid #fff; outline-offset: -2px; }
.md .st i { position: absolute; font-style: normal; font-size: 9px; line-height: 1; pointer-events: none; }
.md .st .sn { left: 7px; top: 7px; font-size: 11px; font-weight: 600; }
.md .st .lt { right: 6px; bottom: 6px; opacity: .8; }
.md .st .nt { left: 0; right: 0; top: 50%; margin-top: -6px; text-align: center; font-size: 12px; font-weight: 600; }
.md .steps.all .sn { display: none; }
.md .steps.all .st .nt { font-size: 8px; margin-top: -4px; }
.md .prow { display: grid; gap: 3px; border-radius: 6px; }
.md .prow.sel { box-shadow: var(--glow); }
.md .prow .nm { border: 0; background: none; text-align: left; font-size: 9px; font-weight: 600; letter-spacing: .08em; white-space: nowrap; overflow: hidden; padding: 0 6px; }
.md .prow.mute .nm { color: #777; text-decoration: line-through; }
.md .prow.mute .st.on { background: linear-gradient(#2f6b40, #1d4a2b); box-shadow: none; }

.md .hold { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; padding: 6px 14px; border-radius: 6px; border: 1px solid #000; background: linear-gradient(#2c2c2c, #0e0e0e); color: #f2f2f2; touch-action: none; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 3px 6px rgba(0,0,0,.4); }
.md .hold strong { font-size: 10px; letter-spacing: .14em; }
.md .hold span { font-size: 8px; letter-spacing: .1em; color: #a8a8a8; }
.md .hold.on { color: var(--g); box-shadow: var(--glow); }
.md .hold.on span { color: var(--g); }
.md .meter { height: 12px; border-radius: 3px; background: #0c0d0d; box-shadow: inset 0 1px 4px rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.6); overflow: hidden; padding: 2px; }
.md .meter i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--g) 0 8px, transparent 8px 11px); }
.md .meter i.hot { background: repeating-linear-gradient(90deg, #fff 0 8px, transparent 8px 11px); }
.md .toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px); z-index: 80; max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 999px; background: #0c0d0d; color: #f4f4f4; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; text-align: center; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.md .toast.on { opacity: 1; transform: translate(-50%, 0); }
.md .none { font-size: 9px; letter-spacing: .08em; color: #555; margin: 0; align-self: center; }
.md .beat { display: inline-flex; gap: 2px; }

/* ---------- desktop console: designed 1440 px wide, scaled to fit ---------- */
.md.desk { display: block; }
.md .md-fit { position: relative; width: 100%; overflow: hidden; overflow: clip; }
.md .md-fit.fs { background: #0a0a0a; height: 100vh; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.md .md-console { width: 1440px; transform-origin: 0 0; padding: 20px; display: flex; flex-direction: column; gap: 12px; background: var(--panel); border-radius: 14px; border: 1px solid #8d8f92; box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 30px 80px rgba(0,0,0,.6); }
.md.desk .row { display: flex; gap: 10px; align-items: stretch; }
.md.desk .hd .logo { display: flex; flex-direction: column; justify-content: center; width: 190px; font-size: 44px; }
.md.desk .logo b { font-weight: 900; }
.md.desk .logo small { font-family: 'Martian Mono', monospace; font-weight: 400; font-variation-settings: normal; font-size: 9px; letter-spacing: .3em; margin-top: 8px; color: var(--mut); }
.md.desk .hd .lcd { flex: 1; padding: 10px 20px; }
.md.desk .hk { display: flex; gap: 8px; align-items: stretch; }
.md.desk .hk .key { min-height: 68px; min-width: 76px; }
.md.desk .sec { flex: 0 0 auto; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.14); overflow: hidden; }
.md.desk .sec.sel { box-shadow: var(--glow); border-color: #0a8f3c; }
.md.desk .sec-t { display: block; width: 100%; height: 26px; border: 0; background: linear-gradient(#2c2c2c, #111); color: #f2f2f2; font-size: 10px; font-weight: 600; letter-spacing: .16em; white-space: nowrap; overflow: hidden; }
.md.desk .sec-t:focus-visible { outline-color: var(--g); outline-offset: -3px; }
.md.desk .sec.sel .sec-t { color: var(--g); }
.md.desk .knobs { display: grid; grid-template-rows: repeat(2, auto); grid-auto-flow: column; grid-auto-columns: 62px; justify-content: center; gap: 8px 0; padding: 10px 3px; }
.md.desk .knobs .kb { width: 62px; }
.md.desk .secs { justify-content: space-between; gap: 6px; }
.md.desk .knobs .kl, .md.desk .knobs .kv { font-size: 8px; }
.md.desk .knobs .kb { --s: 42px; }
.md.desk .blk { display: flex; flex-direction: column; gap: 7px; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.14); min-width: 0; }
.md.desk .keys { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 34px; }
.md.desk .pats { flex: 0 1 auto; } .md.desk .beats { flex: 1 1 280px; min-width: 280px; } .md.desk .scn { flex: 1; }
.md.desk .scn .key.sc { flex: 1 1 0; }
.md.desk .key.sc { min-width: 38px; }
.md.desk .knobs1 { display: flex; gap: 6px; }
.md.desk .knobs1 .kb { width: 62px; gap: 4px; }
.md.desk .fxr .blk { flex: none; } .md.desk .fxr .out { flex: 1; justify-content: flex-start; }
.md.desk .fxr .out .meter { margin-top: 30px; height: 16px; }
.md.desk .repw { display: flex; flex-direction: column; gap: 6px; width: 190px; }
.md.desk .fxr .seg .key { min-width: 62px; min-height: 52px; }
.md.desk .repw .seg .key { min-width: 0; min-height: 30px; }
.md.desk .tools { align-items: center; }
.md.desk .tools .wide .key { min-width: 150px; }
.md.desk .tools .lab { display: flex; align-items: center; gap: 8px; margin-left: 10px; }
.md.desk .tools .lab .key { min-width: 44px; }
.md.desk .selnm { flex: 1; text-align: right; font-family: 'Anybody', sans-serif; font-weight: 800; font-variation-settings: 'wdth' 130; font-size: 22px; text-transform: uppercase; letter-spacing: -.01em; white-space: nowrap; }
.md.desk .steps.one { display: grid; grid-template-columns: repeat(16, 1fr); gap: 7px; }
.md.desk .steps.one .st { height: 92px; }
.md.desk .steps.one .st:nth-child(4n+1) { margin-left: 0; }
.md.desk .steps.all { display: flex; flex-direction: column; gap: 3px; }
.md.desk .steps.all .prow { grid-template-columns: 86px repeat(16, 1fr); }
.md.desk .steps.all .st { height: 24px; }
.md.desk .inst .key { flex: 1 1 0; min-width: 0; min-height: 50px; padding-left: 2px; padding-right: 2px; }
/* ⌘K */
.md .pal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: grid; place-items: start center; padding-top: 12vh; }
.md .pal-box { width: min(560px, 92vw); max-height: 76vh; display: flex; flex-direction: column; background: #0f0f0f; color: #f2f2f2; border: 1px solid #333; border-radius: 12px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.md .pal-in { font: inherit; font-size: 14px; color: #f2f2f2; background: #0f0f0f; border: 0; border-bottom: 1px solid #2a2a2a; padding: 18px 20px; outline: none; -webkit-user-select: text; user-select: text; }
.md .pal-in::placeholder { color: #8a8a8a; }
.md .pal-list { overflow: auto; padding: 6px; flex: 1 1 auto; min-height: 80px; }
.md .pal-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; width: 100%; padding: 10px 14px; border: 0; border-radius: 7px; background: none; color: #e6e6e6; font-size: 12px; text-align: left; }
.md .pal-row.on, .md .pal-row:hover { background: #1d1d1d; color: var(--g); }
.md .pal-row kbd { font: inherit; font-size: 10px; color: #a8a8a8; white-space: nowrap; }
.md .pal .none { color: #a8a8a8; padding: 14px; }
.md .pal-tips { border-top: 1px solid #2a2a2a; padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; max-height: 38vh; overflow: auto; }
.md .pal-tips > * { flex: 0 0 auto; }
.md .pal-tips .cap { color: var(--g); }
.md .pal-tips p { margin: 0; font-size: 10px; line-height: 1.6; color: #b8b8b8; }

/* ---------- phone app: upright, no rotating ---------- */
.md.phone { --s: 42px; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 8px; background: var(--panel); padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); overflow: hidden; touch-action: manipulation; }
.md.phone .phd { display: grid; grid-template-columns: 62px 62px minmax(0, 1fr) auto; gap: 6px; align-items: stretch; }
.md.phone .phd .key.big { min-width: 0; min-height: 56px; font-size: 10px; }
.md.phone .lcd { padding: 6px 10px; gap: 8px; }
.md.phone .lcd .l1 { font-size: 11px; } .md.phone .lcd .l2 { font-size: 8px; } .md.phone .lcd .tp { font-size: 30px; }
.md.phone .logo { display: flex; align-items: center; font-size: 15px; }
.md.phone .pinst { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.md.phone .pinst .key { min-height: 46px; padding-left: 1px; padding-right: 1px; font-size: 8.5px; letter-spacing: .04em; }
.md.phone .mutek { background: linear-gradient(#2c2c2c, #0e0e0e); color: #f2f2f2; border-color: #000; }
.md.phone .psel { display: flex; align-items: center; gap: 6px; min-height: 86px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 0; }
.md.phone .selnm { flex: none; width: 54px; font-family: 'Anybody', sans-serif; font-weight: 800; font-variation-settings: 'wdth' 120; font-size: 15px; line-height: 1; text-transform: uppercase; overflow-wrap: anywhere; }
.md.phone .knobs1 { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.md.phone .knobs1::-webkit-scrollbar { display: none; }
.md.phone .knobs1 .kb { flex: 1 0 46px; }
.md.phone .pview .seg .key { min-height: 36px; }
.md.phone .pstepw { flex: 1; min-height: 150px; display: flex; }
.md.phone .steps { flex: 1; min-height: 0; }
.md.phone .steps.one { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: 1fr 1fr; gap: 6px; touch-action: none; }
.md.phone .steps.all { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; padding: 2px; }
.md.phone .steps.all .prow { grid-template-columns: 52px repeat(16, minmax(0, 1fr)); gap: 2px; flex: none; }
.md.phone .steps.all .st { height: 30px; border-radius: 3px; touch-action: pan-y; }
.md.phone .steps.all .nm { font-size: 8px; padding: 0 2px; letter-spacing: 0; }
.md.phone .pbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.md.phone .pbar .key { min-height: 46px; padding: 0 2px; font-size: 9px; letter-spacing: .06em; }
.md .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); }
.md .sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.5); padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); }
.md .sh-hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.md .sh-hd strong { font-family: 'Anybody', sans-serif; font-weight: 800; font-variation-settings: 'wdth' 130; font-size: 18px; }
.md .sh-hd .x { min-width: 44px; min-height: 44px; }
.md .sh-body { display: flex; flex-direction: column; gap: 12px; }
.md .sheet .keys { display: grid; gap: 6px; }
.md .sheet .keys.two { grid-template-columns: 1fr 1fr; } .md .sheet .keys.three { grid-template-columns: repeat(3, 1fr); } .md .sheet .keys.four { grid-template-columns: repeat(4, 1fr); }
.md .sheet .key { min-height: 48px; }
.md .sheet .key.sw { min-height: 30px; min-width: 52px; }
.md .sheet .beat { display: flex; } .md .sheet .beat .key:first-child { flex: 1; } .md .sheet .beat .x { min-width: 44px; }
.md .sheet .knobs1 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 4px; overflow: visible; }
.md .sheet .knobs1 .kb { --s: 56px; gap: 5px; }
.md .sheet .kl, .md .sheet .kv { font-size: 9px; }
.md .sheet .repw { display: flex; flex-direction: column; gap: 6px; }
.md .sheet .hold { min-height: 64px; }
.md .sheet .note { margin: 0; font-size: 10px; line-height: 1.7; color: var(--mut); }
@media (prefers-reduced-motion: reduce) { .md .key.pend { animation: none; box-shadow: var(--glow); } .md .toast { transition: none; } }
/* phone held sideways: nothing is cut off, the page scrolls instead */
@media (orientation: landscape) and (max-height: 560px) {
  .md.phone { height: auto; min-height: 100dvh; overflow: visible; }
  .md.phone .pinst { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .md.phone .pstepw { flex: none; height: 240px; }
  .md.phone .pbar { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
}
/* the next free scene slot: tap it to save the pattern there */
.md .key.sc.next { border-style: dashed; border-color: #0a8f3c; color: #0a6b2e; font-weight: 600; }
/* phone header: room for the pattern name */
.md.phone .phd { grid-template-columns: 56px 56px minmax(0, 1fr) auto; }
.md.phone .lcd .tp { font-size: 24px; font-variation-settings: 'wdth' 100; }
.md.phone .logo { flex-direction: column; align-items: flex-start; justify-content: center; font-size: 12px; font-variation-settings: 'wdth' 120; line-height: 1; }
.md.phone .steps.all .st .nt { font-size: 7px; letter-spacing: -.06em; margin-top: -3px; }
/* MIXER view (desktop) */
.md.desk .mixp { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.14); }
.md.desk .mixp > .x { position: absolute; right: 8px; top: 6px; }
.md.desk .mixb { display: grid; grid-template-columns: repeat(13, 1fr); gap: 6px; height: 430px; }
.md .strip { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.14); }
.md .strip.sel { box-shadow: var(--glow); border-color: #0a8f3c; }
.md .strip.master { background: rgba(0,0,0,.08); }
.md .strip.mute .fname { color: #777; text-decoration: line-through; }
.md .fval { font-size: 9px; letter-spacing: .04em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.md .flane { flex: 1; min-height: 0; display: flex; gap: 6px; align-items: stretch; }
.md .chm { position: relative; width: 6px; border-radius: 3px; background: #0c0d0d; box-shadow: inset 0 1px 3px rgba(0,0,0,.9); overflow: hidden; }
.md .chm i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--g); }
.md .fader { position: relative; width: 30px; border: 0; border-radius: 4px; background: linear-gradient(90deg, transparent 13px, #0c0d0d 13px 17px, transparent 17px); cursor: ns-resize; touch-action: none; }
.md .fader .ffill { position: absolute; left: 13px; width: 4px; bottom: 0; border-radius: 2px; background: var(--g); }
.md .fader .fthumb { position: absolute; left: 0; right: 0; height: 18px; margin-bottom: -9px; border-radius: 3px; border: 1px solid #555; background: linear-gradient(#fafafa, #c4c6c9 45%, #111 46% 54%, #c4c6c9 55%, #9c9ea1); box-shadow: 0 2px 4px rgba(0,0,0,.45); }
.md .strip .key.sw { min-width: 48px; }
.md .fgap { height: 22px; }
.md .fname { border: 0; background: none; font-size: 9px; font-weight: 600; letter-spacing: .06em; white-space: nowrap; }
.md .ftools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 2px; width: 100%; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md .ftools .kb { --s: 32px; }
.md .ftools .kb:first-child { grid-column: 1 / -1; }
.md .ftools .kl, .md .ftools .kv { font-size: 7.5px; letter-spacing: 0; }
.md .strip.master { justify-content: flex-end; }
.md .strip.master .flane { flex: 0 0 150px; }
/* keyboard and arp */
.md .kctl { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.md .kctl .lab { display: flex; flex-direction: column; gap: 4px; }
.md .kctl .seg .key { min-width: 54px; }
.md .keyb { display: flex; flex-direction: column; gap: 10px; }
.md .kbd { display: flex; gap: 3px; height: 120px; touch-action: none; }
.md .pk { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; border: 1px solid #8d8f92; border-radius: 0 0 6px 6px; background: linear-gradient(#fdfdfd, #d9dadd); box-shadow: var(--keysh); font-size: 9px; color: #333; touch-action: none; }
.md .pk.bl { height: 66%; background: linear-gradient(#2c2c2c, #0e0e0e); color: #cfcfcf; border-color: #000; }
.md .pk.on, .md .pk.held { background: var(--lit); color: #06310f; border-color: #0a8f3c; box-shadow: 0 0 10px rgba(61,255,122,.6); }
.md.phone .pbar { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.md.phone .pbar .key { font-size: 8px; letter-spacing: .02em; }
.md .sheet .kbd { height: 150px; }
.md .sheet .kctl .seg .key { min-width: 44px; min-height: 40px; }
.md .sheet .kctl .key { min-height: 40px; }
.md .pal-grp { padding: 10px 14px 4px; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--g); }
.md .pal-box { width: min(640px, 92vw); }
/* the ring only turns green while the pointer is on the knob or it is being turned */
.md .knob:hover, .md .knob:focus-visible, .md .kb.turn .knob { --arc: var(--g); --trk: #2a2a2a; }
.md .key.next { border-style: dashed; border-color: #0a8f3c; color: #0a6b2e; font-weight: 600; }
.md .lastc { display: flex; align-items: center; gap: 4px; }
.md .lastn { min-width: 22px; text-align: center; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.md.desk .tools .lab .lastc .key.x { min-width: 28px; }
.md .key.rec.on { color: #c21818; }
.md .key.rec.on::before { background: #ff3b3b; box-shadow: 0 0 6px #ff3b3b, 0 0 12px rgba(255,59,59,.7); animation: mdrec 1s steps(2) infinite; }
@keyframes mdrec { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .md .key.rec.on::before { animation: none; } }
.md.desk .hk .key { min-width: 70px; }
.md .key.big.recon { color: #ff5a5a; }
.md.phone .psel .knob { touch-action: pan-x; }
.md .ftools .kb:nth-child(2) { overflow: visible; }
.md .ftools .kb:nth-child(2) .kv { max-width: none; overflow: visible; letter-spacing: -.04em; }
.md.phone .selnm { overflow-wrap: normal; width: 58px; font-size: 11px; }
.md .sheet .kctl .seg .key { padding-left: 6px; padding-right: 6px; letter-spacing: .04em; }

/* ================= phone layout A (2026-11): square step keys, drum keys right above them, nothing hidden sideways ================= */
.md.phone { gap: 6px; padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); overflow-y: auto; overflow-x: hidden; }
.md.phone .phd { grid-template-columns: 54px 54px minmax(0, 1fr) auto; gap: 5px; flex: none; }
.md.phone .phd .key.big { min-height: 44px; min-width: 0; }
.md.phone .lcd { padding: 4px 10px; min-height: 44px; }
/* knobs: name strip, sound row, channel row */
.md.phone .pkn { flex: none; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--line); padding-top: 4px; }
.md.phone .pknm { font-family: 'Anybody', sans-serif; font-weight: 800; font-variation-settings: 'wdth' 120; font-size: 12px; line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
.md.phone .krow { display: flex; gap: 2px; min-height: 66px; }
.md.phone .krow .kb { --s: 44px; flex: 1 1 0; min-width: 0; gap: 1px; padding: 0; }
.md.phone .krow .kl, .md.phone .krow .kv { font-size: 9px; letter-spacing: 0; }
.md.phone .krow .knob { touch-action: none; }
.md.phone .pview { flex: none; }
.md.phone .pview .seg .key { min-height: 44px; }
/* overview + side keys */
.md.phone .pmid { flex: 1 1 144px; min-height: 144px; max-height: 330px; display: flex; gap: 6px; }   /* takes any spare height on tall phones */
.md.phone .pov { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: #0c0d0d; border-radius: 6px; padding: 3px 4px; box-shadow: inset 0 2px 6px rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.6); touch-action: none; overflow: hidden; }
.md.phone .ovr { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 44px repeat(16, minmax(0, 1fr)); gap: 1px; align-items: stretch; }
.md.phone .ovn { font-size: 8px; line-height: 1; letter-spacing: 0; color: #9a9a9a; white-space: nowrap; overflow: hidden; align-self: center; text-transform: uppercase; }
.md.phone .ovr i { background: #232323; border-radius: 1px; margin: 1px 0; }
.md.phone .ovr i.alt { background: #2e2e2e; }
.md.phone .ovr i.on { background: #d8d8d8; }
.md.phone .ovr i.out { opacity: .3; }
.md.phone .ovr.sel .ovn { color: var(--g); font-weight: 600; }
.md.phone .ovr.sel i.on { background: var(--g); box-shadow: 0 0 4px rgba(61,255,122,.7); }
.md.phone .ovr.sel { background: rgba(61,255,122,.1); }
.md.phone .ovr.mute .ovn { text-decoration: line-through; color: #666; }
.md.phone .ovr.mute i.on { background: #555; box-shadow: none; }
.md.phone .ovh { position: absolute; left: 49px; right: 4px; top: 3px; bottom: 3px; display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 1px; pointer-events: none; }
.md.phone .ovh i.ph { background: rgba(255,255,255,.22); border-radius: 1px; }
.md.phone .pside { flex: none; width: 76px; display: flex; flex-direction: column; gap: 6px; justify-content: space-between; }
.md.phone .pside .key { flex: 1 1 0; min-height: 44px; max-height: 72px; padding-left: 2px; padding-right: 2px; font-size: 9px; letter-spacing: .04em; }
/* whole pattern (only in that view) */
.md.phone .pgrid { display: none; flex: 1 1 0; min-height: 120px; }
.md.phone.vall .pgrid { display: flex; }
.md.phone.vall .pkn, .md.phone.vall .pmid, .md.phone.vall .pinst { display: none; }
.md.phone .pgrid .steps.all { flex: 1; min-height: 0; }
.md.phone .pgrid .steps.all .prow { grid-template-columns: 54px repeat(16, minmax(0, 1fr)); }
.md.phone .pgrid .steps.all .st { height: 34px; }
.md.phone .pgrid .steps.all .nm { min-height: 34px; font-size: 8.5px; }
/* scenes */
.md.phone .pscn { flex: none; display: flex; gap: 4px; }
.md.phone .pscn .key { min-height: 44px; }
.md.phone .pscn .key.sc { flex: 0 1 44px; min-width: 0; padding: 0; font-size: 13px; font-weight: 600; }
.md.phone .pscn .key.add { flex: 1 1 0; min-width: 44px; padding: 0 4px; font-size: 9px; letter-spacing: .06em; white-space: normal; line-height: 1.25; }
@media (max-width: 340px) { .md.phone .logo { display: none; } }
/* drum keys 7 x 2, then the 16 step keys 8 x 2, all 44 px tall */
.md.phone .pinst { flex: none; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.md.phone .pinst .key { min-height: 44px; padding: 13px 1px 3px; font-size: 8px; letter-spacing: 0; line-height: 1.05; white-space: normal; overflow-wrap: normal; }
.md.phone .pinst .key.led::before { top: 4px; width: 5px; height: 5px; margin-left: -2.5px; }
.md.phone .pstepw { flex: none; min-height: 0; display: block; }
.md.phone .pstepw .steps.one { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: 44px 44px; gap: 4px; touch-action: none; }
.md.phone .pstepw .st .sn { left: 5px; top: 5px; font-size: 10px; }
.md.phone .pbar { flex: none; margin-top: auto; }
.md.phone .pbar .key { min-height: 44px; font-size: 9px; }
/* short screens (a browser tab with its bars, small phones): the overview folds away first, and the page can still scroll */
@media (max-height: 735px) { .md.phone .pmid { display: none; } .md.phone .pscn { margin-top: auto; } .md.phone .pbar { margin-top: 0; } .md.phone.vall .pscn { margin-top: 0; } }   /* spare height goes above the scenes, so scenes, drums, steps and bar stay together at the bottom */
@media (orientation: landscape) and (max-height: 560px) { html[data-layout="phone"] body { overflow: visible; } .md.phone .pkn { flex-direction: row; column-gap: 12px; align-items: center; } .md.phone .pknm { flex: 0 0 70px; } .md.phone .krow { flex: 1 1 0; min-width: 0; } .md.phone .pinst { grid-template-columns: repeat(14, minmax(0, 1fr)); } .md.phone .pstepw { height: auto; } .md.phone .pstepw .steps.one { grid-template-columns: repeat(16, minmax(0, 1fr)); grid-template-rows: 44px; } .md.phone .pbar { position: static; } }

/* dialogs: install steps, sign-up */
.md .dlg { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.62); display: grid; place-items: center; padding: 16px; }
.md .dlg-box { width: min(440px, 100%); max-height: 90dvh; overflow: auto; background: #0f0f0f; color: #f2f2f2; border: 1px solid #333; border-radius: 14px; padding: 18px 20px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.7); -webkit-user-select: text; user-select: text; }
.md .dlg-hd { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.md .dlg-hd strong { font-family: 'Anybody', sans-serif; font-weight: 800; font-variation-settings: 'wdth' 130; font-size: 20px; }
.md .dlg-hd .x { min-width: 40px; min-height: 40px; }
.md .dlg-body p { margin: 0 0 12px; font-size: 12px; line-height: 1.65; color: #d6d6d6; }
.md .su { display: flex; flex-direction: column; gap: 12px; }
.md .su-l { display: flex; flex-direction: column; gap: 5px; }
.md .su-l .cap { color: #b8b8b8; }
.md .su input { font: inherit; font-size: 16px; color: #f2f2f2; background: #1b1b1b; border: 1px solid #4a4a4a; border-radius: 8px; padding: 12px 14px; min-height: 48px; -webkit-user-select: text; user-select: text; }
.md .su input:focus-visible { outline: 2px solid var(--g); outline-offset: 2px; }
.md .su .key.big, .md[data-theme="dark"] .su .key.big { box-shadow: none; min-height: 52px; font-size: 12px; background: var(--g); color: #0a0a0a; border-color: var(--g); }
.md .su .key.big:disabled { opacity: .6; }
.md .su-msg { min-height: 1.4em; margin: 0 !important; color: #ffd27a !important; }
.md .su-note { font-size: 10px !important; color: #a8a8a8 !important; margin: 0 !important; }
/* MIDI panel */
.md .mstat { margin: 0; font-size: 10px; letter-spacing: .06em; line-height: 1.6; }
.md.desk .note { margin: 0; max-width: 900px; font-size: 10px; line-height: 1.7; color: var(--mut); }
.md .mlist { display: flex; flex-wrap: wrap; gap: 6px; }
.md .mlist .key { text-transform: none; letter-spacing: .02em; }
.md .sheet .mlist .key { min-height: 40px; }

/* drum keys: corner letter, muted and solo states */
.md .key.inst .lt { position: absolute; right: 5px; bottom: 4px; font-style: normal; font-size: 8px; opacity: .55; pointer-events: none; }
.md .key.inst.mute::before { background: #ff3b3b; box-shadow: 0 0 6px rgba(255,59,59,.8); }
.md .key.inst.mute, .md .key.inst.quiet { opacity: .6; }
.md .key.inst.solo::before { background: #ffd23b; box-shadow: 0 0 6px rgba(255,210,59,.9); }
.md .key.inst.solo { font-weight: 600; }
.md.desk.armed .md-console { border-color: #0a8f3c; }
.md.kbopen .steps .st .lt { display: none; }
.md .pk .pl { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font-style: normal; font-size: 9px; opacity: .6; pointer-events: none; }
.md .pk { position: relative; }
.md.desk .tools .wide .key { min-width: 118px; }
.md.desk .hk .key { min-width: 62px; }
.md .pal-row kbd { font-size: 12px; }
/* phone: header stays usable above an open sheet; messages appear at the top; tempo is its own tap target */
.md.phone .phd { position: relative; z-index: 45; }
.md.phone .toast { top: calc(60px + env(safe-area-inset-top)); bottom: auto; transform: translate(-50%, -12px); }
.md.phone .toast.on { transform: translate(-50%, 0); }
.md.phone .lcd .tp { padding: 6px 2px 6px 8px; margin: -6px 0; }
/* phone, short screens: the overview folds away but CHAIN, LAST and MUTE stay as one row */
@media (max-height: 735px) and (min-height: 600px) { .md.phone .pmid { display: flex; flex: none; min-height: 0; height: 44px; } .md.phone .pmid .pov { display: none; } .md.phone .pside { flex-direction: row; width: 100%; } .md.phone .pside .key { max-height: none; } .md.phone .pscn { margin-top: 0; } .md.phone .pbar { margin-top: auto; } }
/* first-run tips: one slim line under the desktop header; on the phone it shares the drum-name line */
.md.desk .hint { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 2px 0 12px; border: 1px dashed var(--line); border-radius: 8px; color: var(--mut); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
.md.desk .hint span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.md.desk .hint .key.x { flex: none; font-size: 11px; }
.md.phone .pknm { display: flex; align-items: center; gap: 10px; }
.md.phone .pknm > span { flex: none; }
.md.phone .hint { position: relative; flex: 1 1 0; min-width: 0; height: 12px; margin: 0; padding: 0; border: 0; background: none; display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--mut); font: 400 8px/12px 'Martian Mono', ui-monospace, monospace; font-variation-settings: 'wdth' 75; letter-spacing: 0; text-transform: uppercase; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.md.phone .hint::before { content: ''; position: absolute; inset: -10px 0 -8px; }   /* a finger-sized target for a 12 px line */
.md.phone .hint span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.md.phone .hint i { flex: none; font-style: normal; font-size: 10px; color: var(--ink); }
@media (orientation: landscape) and (max-height: 560px) { .md.phone .hint { display: none; } }
/* type a tempo: the value under TEMPO (and the number in the desktop display) becomes a small number box */
.md .kv.ed, .md.desk .lcd .tp { cursor: text; }
.md .kv.ed { text-decoration: underline dotted; text-underline-offset: 2px; }
.md .tin { font-family: inherit; box-sizing: border-box; padding: 0; border: 0; border-radius: 3px; background: #0c0d0d; color: var(--g); text-align: center; -webkit-user-select: text; user-select: text; -moz-appearance: textfield; appearance: textfield; }
.md .tin::-webkit-outer-spin-button, .md .tin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.md .kb:has(.tin) { overflow: visible; }
.md .kb .tin { width: 44px; height: 16px; margin: -4px 0 -3px; font-size: 11px; letter-spacing: 0; overflow: visible; text-decoration: none; }
.md.phone .kb .tin { width: 58px; height: 26px; margin: -9px 0 -7px; font-size: 16px; }
.md .lcd input.tp { width: 2.4em; height: 1em; background: none; border-radius: 4px; text-align: right; }
