html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;
  font-family: system-ui, sans-serif;
  background: #111;
  color: #eee;
}

#screen { height: 100vh; height: 100dvh; position: relative; overflow: hidden; }

.screen { height: 100%; display: flex; flex-direction: column; }

.top-half {
  flex: 0 0 50%;
  overflow: hidden;
  padding: .5rem;
  box-sizing: border-box;
}

.editor-header {
  flex: 0 0 auto;
  overflow: hidden;
  padding: .5rem;
  box-sizing: border-box;
}

.app-title { text-align: center; margin-top: 2rem; }

.breadcrumb { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.crumb { flex: 1; }

.toolbar { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.tempo { display: flex; align-items: center; gap: .4rem; }

/* Every button that isn't one of the big on-screen keyboard/keypad tiles
   (.key / .kb-btn, sized by the grid they live in) was left at the
   browser's tiny default button size. Give them all a comfortable, equal
   touch target. */
.back-btn,
.playstop-btn,
.tempo-minus,
.tempo-plus,
.root-btn,
.scale-btn,
.waveform-btn {
  min-height: 2.75rem;
  padding: .5rem 1rem;
  font-size: 1.05rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #222;
  color: #eee;
  cursor: pointer;
}

.tempo-minus, .tempo-plus { min-width: 2.75rem; padding: .5rem; }

.keypad {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50%;
  z-index: 999;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
  background: #000;
  box-sizing: border-box;
}

.keyboard {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50%;
  z-index: 999;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
  background: #000;
  box-sizing: border-box;
}

.key, .kb-btn {
  border: 1px solid #333;
  background: #222;
  color: #eee;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.key.has-content, .clip-key.has-content, .track-key.has-content, .project-key.has-content {
  background: #2a5;
}

.key.active-clip, .clip-key.active-clip {
  background: #a52;
  border: 2px solid #fff;
}
.key.active-clip.has-content { background: #a52; box-shadow: inset 0 0 0 4px #2a5; }

.key.inactive { visibility: hidden; cursor: default; }

.kb-btn.current { background: #35a; border: 2px solid #fff; }
.kb-btn.empty { visibility: hidden; }
.waveform-btn.current { background: #35a; }

.step-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: .25rem .5rem 55vh .5rem;
  box-sizing: border-box;
}

.step-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 0;
  min-height: 3.25rem;
  box-sizing: border-box;
  border-bottom: 1px solid #333;
}

.step-row.playhead { background: #444a00; }

.step-no { width: 1.8rem; text-align: right; opacity: .7; font-size: 1.05rem; flex: 0 0 auto; }

.trig-btn, .pitch-btn, .dur-btn, .velo-btn {
  flex: 1 1 0;
  min-height: 2.75rem;
  padding: .5rem .3rem;
  font-size: 1.05rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #222;
  color: #eee;
  cursor: pointer;
}

.del-btn {
  flex: 0 0 auto;
  min-width: 2.5rem;
  min-height: 2.75rem;
  font-size: 1.3rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #222;
  color: #eee;
  cursor: pointer;
}

.add-btn {
  min-height: 2.75rem;
  min-width: 4rem;
  font-size: 1.4rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #222;
  color: #eee;
  cursor: pointer;
}

.trig-btn { background: #333; }
.trig-btn.on { background: #d33; }

.playstop-btn { background: #444; }
.playstop-btn.playing { background: #2a5; }

button:disabled { opacity: .3; }
