@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* Black and white. The only colour comes from the tracks and drums (--c). */
:root {
  --bg: #000;
  --text: #fff;
  --dim: #8c8c8c;
  --line: #333;
  --outline: #666;
  --fill: #161616;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: 'tnum', 'cv11';
}

/* Buttons are outlined by default; .primary and .on are solid white */
button,
select,
input[type='number'],
input[type='text'] {
  border-radius: 0;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--outline);
  padding: 6px 12px;
  cursor: pointer;
}
.icon {
  display: inline-flex;
  flex: none;
  width: 16px;
  height: 16px;
}
.icon svg {
  width: 100%;
  height: 100%;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
}
.icon-btn {
  padding: 6px 10px;
}
button:hover,
select:hover,
input[type='number']:hover,
input[type='text']:hover {
  border-color: var(--text);
}
button.primary,
button.on {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
button.primary:hover {
  background: #d9d9d9;
  border-color: #d9d9d9;
}
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
select {
  background: var(--bg);
}
input[type='number'],
input[type='text'] {
  border-color: var(--line);
  cursor: text;
}
input[type='number'] {
  width: 68px;
}
input[type='text'] {
  width: 170px;
}
input::placeholder {
  color: var(--dim);
}
input[type='range'] {
  accent-color: var(--text);
}

.dim {
  color: var(--dim);
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 12px 0 0;
}
header label {
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
#play {
  min-width: 76px;
}
#rec.on .icon {
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  to {
    visibility: hidden;
  }
}
.song {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Dropdown menu under a header button */
.menu-wrap {
  position: relative;
}
#song-label {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: 280px;
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--text);
}
.menu[hidden] {
  display: none;
}
header .menu label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}
.menu input[type='text'],
.menu select {
  width: 100%;
  font-size: 14px;
}
.menu button {
  justify-content: flex-start;
}
#dev-menu {
  width: 380px;
}
.menu .label {
  font-size: 12px;
}
.menu hr {
  width: 100%;
  margin: 2px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

main {
  padding: 8px 20px 40px;
}
h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fold {
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.fold:hover {
  color: var(--text);
}
[hidden] {
  display: none !important;
}
#sections,
#arr {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#sections button {
  min-width: 40px;
  font-weight: 700;
}
/* queued to start at the end of the loop */
#sections button.next {
  border-style: dashed;
  border-color: var(--text);
}
#sec-name {
  width: 110px;
}
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--outline);
}
.chip.now {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}
.chip .lbl {
  padding: 0 6px 0 10px;
  font-weight: 600;
}
.chip button {
  border: 0;
  padding: 6px 7px;
  color: inherit;
}
section.folded > :not(h2) {
  display: none !important;
}
section.folded .fold .icon:last-child {
  transform: rotate(-90deg);
}

body[data-view='session'] #view-sampler,
body[data-view='sampler'] #view-session {
  display: none;
}
.tabs {
  display: flex;
  margin-right: 12px;
}
.tabs button:last-child {
  margin-left: -1px;
}

/* Sampler */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.bar label {
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.bar input[type='range'] {
  width: 110px;
}
.sep {
  width: 1px;
  height: 22px;
  background: var(--line);
}
#sample {
  max-width: 320px;
}
#wave {
  display: block;
  width: 100%;
  height: 240px;
  background: var(--bg);
  border: 1px solid var(--line);
  touch-action: none;
}
.hint {
  font-size: 12px;
  margin: 6px 0 0;
}
#pads {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.pad {
  min-height: 52px;
  font-weight: 700;
  border-color: var(--text);
}
.pad:disabled {
  border-color: var(--line);
  color: var(--dim);
  cursor: default;
}
.pad.now {
  background: var(--text);
  color: var(--bg);
}
#use-in {
  display: flex;
  gap: 6px;
}
#use-in button {
  font-weight: 700;
  border-color: var(--c);
  color: var(--c);
}
#use-in button:hover {
  background: var(--c);
  color: var(--bg);
}
body.dropping::after {
  content: 'Drop to add to your samples';
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  background: rgba(0, 0, 0, 0.88);
  font-size: 22px;
  pointer-events: none;
}

/* Loop tracks */
.lane {
  display: grid;
  grid-template-columns: 40px 130px auto auto 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}
/* controls match the height of a closed lane */
.lane > button,
.lane > select {
  height: 56px;
}
.lane .name {
  font-weight: 700;
  border-color: var(--c);
  color: var(--c);
  padding: 6px 0;
}
.lane.sel .name {
  background: var(--c);
  color: var(--bg);
}
.lane canvas {
  width: 100%;
  height: 56px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
}
.lane canvas {
  touch-action: none;
}
.lane.sel canvas {
  border-color: var(--c);
  height: 190px;
}

#knobs {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
}
#knobs label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--dim);
  min-width: 0;
}
#knobs input {
  width: 100%;
  accent-color: var(--c);
}
#knobs label:last-child input {
  accent-color: var(--text);
}

/* Drum grid */
.drow {
  display: grid;
  grid-template-columns: 96px repeat(16, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.drow .name {
  justify-content: flex-start;
  padding: 6px 10px;
  border-color: var(--line);
}
.drow .name:hover {
  border-color: var(--text);
}
.drow.sel .name {
  border-color: var(--c);
  color: var(--c);
}
.cell {
  padding: 0;
  min-height: 30px;
  border-color: var(--line);
}
/* first step of each beat */
.cell:nth-child(4n + 2) {
  background: var(--fill);
  border-color: var(--outline);
}
.cell.on {
  background: var(--c);
  border-color: var(--c);
}
.cell.now {
  box-shadow: inset 0 0 0 2px var(--text);
}

.dev {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
#monitor {
  margin: 0;
  font: 12px/1.6 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  #knobs {
    grid-template-columns: repeat(4, 1fr);
  }
  .lane {
    grid-template-columns: 40px 1fr auto auto;
  }
  .lane canvas {
    grid-column: 1 / -1;
  }
  .drow {
    grid-template-columns: 64px repeat(16, 1fr);
    gap: 2px;
  }
  #pads {
    grid-template-columns: repeat(4, 1fr);
  }
}
