:root {
  color-scheme: dark;
  --bg: #2b3035; --panel: #343a40; --deep: #1e2225; --edge: #14171a;
  --text: #cfd6db; --dim: #808a91; --accent: #ff8c1a; --green: #9ccc3c;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body { height: 100%; margin: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text); font: 12px/1.3 "Segoe UI", Tahoma, Verdana, sans-serif; }

button, select, input[type=number], input[type=text] {
  font: inherit; color: var(--text); background: #2a2f33;
  border: 1px solid var(--edge); border-radius: 3px; padding: 4px 9px;
}
button { cursor: pointer; }
button:hover { background: #40474d; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=range] { accent-color: var(--accent); }

header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 6px 10px;
  background: #3b4147; border-bottom: 1px solid var(--edge); }
.logo { font-size: 15px; font-weight: 700; color: #e8ecef; margin-right: 4px; }
.transport { display: flex; gap: 4px; }
#play, #stop { position: relative; width: 36px; height: 28px; padding: 0; }
#play::before { content: ""; position: absolute; left: 13px; top: 7px;
  border-left: 11px solid var(--green); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
#play.on { background: #46562c; }
#stop::before { content: ""; position: absolute; left: 12px; top: 9px; width: 11px; height: 11px; background: #c9d1d6; }
.lcd { display: flex; align-items: center; gap: 6px; padding: 2px 8px; background: #14181a;
  border: 1px solid #0d0f10; border-radius: 3px; color: var(--dim); }
#bpm { width: 56px; padding: 0; background: transparent; border: 0; color: var(--accent);
  font: 700 18px Consolas, "Courier New", monospace; text-align: right; }
.knob { display: flex; align-items: center; gap: 5px; color: var(--dim); }
.knob input { width: 80px; }
#title { width: 140px; }
.spacer { flex: 1; }

#main { flex: 1; display: flex; min-height: 0; }
#browser { width: 150px; flex: none; padding: 8px 6px; overflow: auto; background: var(--deep); border-right: 1px solid var(--edge); }
#browser h3 { margin: 0 0 6px 6px; font-size: 12px; font-weight: 600; color: var(--dim); }
#presets button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 6px; }
#presets button:hover { background: #2d3338; color: #fff; }
#work { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px; }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 3px; }
.panel.grow { flex: 1; }
.title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 4px 8px;
  background: #2f353a; border-bottom: 1px solid var(--edge); color: var(--dim); }
.title label { display: flex; align-items: center; gap: 4px; }
.title select { padding: 2px 4px; }

#rack { overflow-x: auto; padding: 5px 0; }
.row { display: flex; align-items: center; gap: 6px; min-width: 660px; padding: 2px 8px; }
.led { width: 12px; height: 12px; padding: 0; border-radius: 50%; background: #243018; }
.led.lit { background: var(--green); box-shadow: 0 0 4px #7fb02a; }
.name { width: 92px; text-align: left; }
.vol { width: 70px; }
.steps { display: flex; gap: 2px; }
.steps b { width: 24px; height: 26px; border-radius: 2px; background: #4a5158; border: 1px solid #22272b; cursor: pointer; }
.steps b.g1 { background: #5c636a; }
.steps b.on { background: var(--accent); border-color: #a8530a; }
.steps.ro b { cursor: default; }
.ruler span { width: 186px; }
.ruler i { width: 24px; font-size: 10px; font-style: normal; text-align: center; color: var(--dim); }
.now { filter: brightness(1.45); }
.ruler i.now { color: #fff; filter: none; }

#roll { flex: 1; overflow: auto; position: relative; }
#rollruler { display: flex; position: sticky; top: 0; z-index: 3; min-width: 560px;
  padding-left: 56px; background: var(--panel); border-bottom: 1px solid var(--edge); }
#rollruler i { flex: 1; font-size: 10px; font-style: normal; padding-left: 3px; color: var(--dim); }
#rollruler i.now { color: #fff; }
#rollbody { display: flex; min-width: 560px; }
#keys { flex: none; width: 56px; position: sticky; left: 0; z-index: 2; }
.key { height: 15px; padding-right: 3px; text-align: right; font-size: 9px; line-height: 15px;
  border-bottom: 1px solid #1b1f22; color: #444; cursor: pointer; }
.key.wht { background: #d8dde0; }
.key.blk { background: linear-gradient(90deg, #202427 62%, #d8dde0 62%); }
.key.dim { opacity: .45; }
.key.root { box-shadow: inset 3px 0 var(--accent); }
#grid { flex: 1; position: relative; display: grid; grid-template-columns: repeat(16, 1fr);
  grid-auto-rows: 15px; background: #252a2e; }
.c { border-left: 1px solid #2d3337; border-bottom: 1px solid #1e2225; cursor: crosshair; }
.c.beat { border-left-color: #4b5359; }
.c.blk { background: #202427; }
.c.out { background: #181b1d; }
.c.head, .c.tail { background: var(--accent); box-shadow: inset 0 0 0 1px #a8530a; }
.c.tail { background: #e07a10; border-left-color: transparent; }
#playhead { position: absolute; top: 0; bottom: 0; width: 6.25%; display: none;
  background: rgba(255, 255, 255, .08); pointer-events: none; }

footer { display: flex; justify-content: space-between; gap: 10px; padding: 3px 10px;
  background: #23282b; border-top: 1px solid var(--edge); color: var(--dim); }

@media (max-width: 720px) { #browser { display: none; } }

button.active { background: #5b4a2c; color: #ffb35c; }
#rec.active { background: #7d2c25; color: #fff; }
.title input[type=number] { width: 48px; padding: 2px 4px; }
.title button { padding: 2px 8px; }

#work { overflow-y: auto; }
.panel { flex: none; }
.panel.grow { flex: 1 0 380px; }
#voiceview { display: block; width: 100%; height: 56px; background: #1b1f22; }
#vrec.active { background: #7d2c25; color: #fff; }
#synth { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 10px; }
.sk { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 82px; color: var(--dim); }
.sk input[type=range] { width: 76px; }
.sk select { padding: 2px 4px; width: 82px; }
.sk output { color: var(--accent); font-family: Consolas, "Courier New", monospace; }

/* playlist, mixer, automation, velocity */
#arrwrap { overflow-x: auto; padding: 4px 6px 6px; }
#arrruler, #arr { display: grid; grid-template-columns: repeat(32, minmax(26px, 1fr)); gap: 2px; min-width: 880px; }
#arrruler i { font-size: 10px; font-style: normal; text-align: center; color: var(--dim); cursor: pointer; }
#arrruler i:hover { color: #fff; }
#arr b { height: 30px; border-radius: 2px; background: #3f464c; border: 1px solid #22272b; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; }
#arr b.lp { border-color: var(--accent); }
.row.sel .name { border-color: var(--accent); color: var(--accent); }

#mixer { display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.mx { flex: none; width: 96px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px; background: #2b3035; border: 1px solid var(--edge); border-radius: 3px; }
.mx.master { width: 140px; }
.mn { font-weight: 600; max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf { display: flex; gap: 6px; height: 96px; }
.fader { writing-mode: vertical-lr; direction: rtl; width: 22px; height: 96px; }
.meter { width: 10px; height: 96px; background: #14181a; position: relative; border: 1px solid #0d0f10; }
.meter i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--green); }
.meter i.hot { background: #d9442f; }
.mx label { display: flex; flex-direction: column; align-items: center; color: var(--dim); font-size: 10px; }
.mx label input { width: 80px; }
.mb button { width: 30px; padding: 2px 0; }
.mb [data-b=mute].active { background: #7d2c25; color: #fff; }
.mb [data-b=solo].active { background: #6b5d1e; color: #ffe066; }

#velrow { position: sticky; bottom: 0; z-index: 3; display: flex; min-width: 560px;
  background: var(--panel); border-top: 1px solid var(--edge); }
#velrow span { flex: none; width: 56px; padding: 3px; font-size: 9px; color: var(--dim); text-align: right; }
#vel { flex: 1; display: grid; height: 48px; cursor: ns-resize; touch-action: none; }
#vel div { position: relative; border-left: 1px solid #2d3337; }
#vel div.beat { border-left-color: #4b5359; }
#vel i { position: absolute; left: 25%; right: 25%; bottom: 0; background: var(--accent); border-radius: 2px 2px 0 0; }

#autolane { position: relative; display: grid; height: 70px; margin: 6px; background: #252a2e;
  cursor: crosshair; touch-action: none; }
.ac { position: relative; border-left: 1px solid #2d3337; }
.ac.beat { border-left-color: #4b5359; }
.ac i { position: absolute; left: 10%; right: 10%; bottom: 0; background: #6ab0ff; border-radius: 2px 2px 0 0; }
#autolane u { position: absolute; left: 0; right: 0; border-top: 1px dashed #808a91; pointer-events: none; text-decoration: none; }
#mode.active, #loopOn.active { background: #46562c; color: #d6f08a; }
#defVel { width: 70px; }
#trackName { width: 90px; padding: 2px 4px; }

/* foldable panels, note selection, project box */
.title { cursor: pointer; user-select: none; }
.title > * { cursor: default; }
.title::before { content: "\25BE"; color: var(--accent); }
.panel.collapsed .title::before { content: "\25B8"; }
.panel.collapsed > :not(.title) { display: none; }
.panel.collapsed .title > * { display: none; }
.panel.collapsed.grow { flex: none; }
.c.sel { outline: 2px solid #fff; outline-offset: -2px; }
.box { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; }
.mx select { width: 84px; padding: 2px 4px; }

/* audio clips, long patterns, drum lane, song automation */
.steps b, .ruler i { flex: none; }
.row { width: max-content; }
#rollruler, #rollbody, #velrow { min-width: var(--rw, 560px); }
#atracks { display: flex; }
#alabels { flex: none; width: 92px; padding-top: 18px; background: #2a2f33; border-right: 1px solid var(--edge); }
.alabel { height: 52px; padding: 4px 6px; cursor: pointer; color: var(--dim); border-bottom: 1px solid var(--edge);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alabel.sel { color: var(--accent); background: #343a40; }
#awrap { position: relative; flex: 1; overflow-x: auto; }
#aview { display: block; touch-action: none; }
#aplayhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; opacity: .6; display: none; pointer-events: none; }
#dvelwrap { overflow-x: auto; padding: 6px; }
#dvel { display: grid; height: 56px; background: #252a2e; cursor: ns-resize; touch-action: none; }
#dvel div { position: relative; border-left: 1px solid #2d3337; }
#dvel i { position: absolute; left: 20%; right: 20%; bottom: 0; background: var(--accent); border-radius: 2px 2px 0 0; }
#sauto { display: grid; grid-template-columns: repeat(32, minmax(26px, 1fr)); gap: 2px; min-width: 880px; margin-top: 4px;
  touch-action: none; cursor: crosshair; }
#sauto b { position: relative; height: 44px; background: #252a2e; border-radius: 2px; }
#sauto i { position: absolute; left: 15%; right: 15%; bottom: 0; background: #6ab0ff; border-radius: 2px 2px 0 0; }
#ccLearn.active { background: #46562c; color: #d6f08a; }