/* Co-Operator's dark look: its tokens, its type, its square buttons. */
:root {
  --f-mono: "Silkscreen", ui-monospace, monospace;
  --f-sans: "Pixelify Sans", "Silkscreen", system-ui, sans-serif;
  --ground: #0a0a0a;
  --panel: #181818;
  --btn-bg: #000000;
  --inset: #0d0d0d;
  --cell: #1c1c1c;
  --cell-hi: #282828;
  --ink: #dcdcdc;
  --muted: #a0a0a0;
  --line: #3d3d3d;
  --line-hard: #949494;
  --grid-edge: #484848;
  --lit-bg: #ffffff;
  --lit-ink: #0a0a0a;
  --slate: #8f8f8f;
  --tint-ink: #0d0d0d;
  --red: #ea546f; --orange: #ff9064; --sand: #ffd98a; --lime: #bdf78d;
  --green: #4ad882; --teal: #3ab6c2; --navy: #5266bd; --blue: #6180e6;
  --sky: #5cbcff; --plum: #b45fb4;
  --p0: var(--red); --p1: var(--orange); --p2: var(--teal); --p3: var(--green);
  --p4: var(--blue); --p5: var(--plum); --p6: var(--sky); --p7: #8a93a0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body {
  font-family: var(--f-mono); font-size: 12px; line-height: 1.4;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: none; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}
button, input { font-family: inherit; color: inherit; font-size: inherit; }
button {
  cursor: pointer; border-radius: 0;
  background: var(--btn-bg); color: var(--ink);
  border: 2px solid var(--line-hard); box-shadow: 2px 2px 0 var(--slate);
  padding: 5px 10px; min-height: 32px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: none; background: var(--lit-bg); color: var(--lit-ink); border-color: var(--lit-bg); }
button[aria-pressed="true"] { background: var(--lit-bg); color: var(--lit-ink); border-color: var(--lit-bg); }
button:disabled { background: var(--ground); color: #5a5a5a; border-color: var(--grid-edge); box-shadow: none; cursor: default; }
button:focus-visible, canvas:focus-visible, input:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }

.app { max-width: 980px; margin: 0 auto; padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.top { display: flex; align-items: center; gap: 12px; min-width: 0; }
h1 { margin: 0; font-size: clamp(17px, 5.6vw, 26px); line-height: 1.1; text-transform: uppercase; font-weight: 400; white-space: nowrap; }
.song { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-sans); font-size: 14px; }

.stage { position: relative; background: var(--inset); border: 2px solid var(--line); height: min(46vh, 420px); min-height: 220px; overflow: hidden; touch-action: none; cursor: grab; }
.stage.dragging { cursor: grabbing; }
.stage.over { border-color: var(--sand); }
#roll { display: block; width: 100%; height: 100%; }
.drop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 16px; text-transform: uppercase; pointer-events: none; }
.drop[hidden] { display: none; }
.stage.over .drop { color: var(--sand); }

.transport { background: var(--panel); border: 2px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ctl { flex-wrap: wrap; }
.play { min-width: 72px; }
.time { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 92px; }
#seek { flex: 1; min-width: 0; height: 36px; display: block; background: var(--inset); border: 2px solid var(--line); cursor: pointer; touch-action: none; }
.knob { display: flex; align-items: center; gap: 8px; color: var(--muted); text-transform: uppercase; }
.knob span { color: var(--ink); min-width: 38px; text-align: center; }
#wavBtn { margin-left: auto; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 120px; height: 24px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; background: var(--inset); border: 2px solid var(--line); }
input[type=range]::-moz-range-track { height: 6px; background: var(--inset); border: 2px solid var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 20px; margin-top: -9px; background: var(--ink); border: 2px solid var(--ground); border-radius: 0; }
input[type=range]::-moz-range-thumb { width: 12px; height: 20px; background: var(--ink); border: 2px solid var(--ground); border-radius: 0; }

.tracks { display: flex; flex-direction: column; gap: 6px; }
.trk { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 2px solid var(--line); border-top: 3px solid var(--c); padding: 6px 8px; min-width: 0; }
.trk.off { opacity: .45; }
.lamp { width: 14px; height: 14px; flex: none; background: var(--cell); border: 2px solid var(--c); }
.tname { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-sans); font-size: 14px; }
.snd { display: flex; align-items: stretch; gap: 0; flex: 2 1 220px; min-width: 0; }
.snd button { min-height: 34px; }
.snd .step { width: 34px; padding: 0; flex: none; }
.snd .which { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 6px; }
.snd .which.loading { color: var(--muted); }
.trk .ms { width: 34px; padding: 0; flex: none; }
.trk .ms.mute[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: var(--tint-ink); }
.trk .ms.solo[aria-pressed="true"] { background: var(--sand); border-color: var(--sand); color: var(--tint-ink); }

.trk .kn { flex: none; padding: 0 8px; }
.trk .kn[aria-expanded="true"] { background: var(--lit-bg); color: var(--lit-ink); border-color: var(--lit-bg); }
.knobstrip { background: var(--panel); border: 2px solid var(--line); border-top: 0; margin-top: -6px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.knobstrip[hidden] { display: none; }
.kgroup { display: flex; flex-direction: column; gap: 6px; }
.envlab { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
/* Co-Op's knob: label and readout over a dithered track with a square thumb. */
.knobstrip .knobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 11px 14px; }
.knobstrip .knob { display: flex; flex-direction: column; align-items: stretch; gap: 0; min-width: 0; touch-action: manipulation; text-transform: none; }
.knobstrip .knob span { min-width: 0; text-align: left; }
.knobstrip .knob .k { font-family: var(--f-mono); font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; white-space: nowrap; gap: 6px; }
.knobstrip .knob .k b { font-size: 15px; font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.knobstrip .knob input[type=range] { width: 100%; height: 30px; }
.knobstrip .knob input[type=range]::-webkit-slider-runnable-track { height: 8px; border: 0; background: repeating-conic-gradient(#8c8c8c 0% 25%, #0a0a0a 0% 50%) 50% / 4px 4px; box-shadow: inset 0 0 0 2px var(--ink); }
.knobstrip .knob input[type=range]::-moz-range-track { height: 8px; border: 0; background: #0d0d0d; box-shadow: inset 0 0 0 2px var(--ink); }
.knobstrip .knob input[type=range]::-webkit-slider-thumb { width: 18px; height: 28px; margin-top: -10px; background: #ffffff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--slate); }
.knobstrip .knob input[type=range]::-moz-range-thumb { width: 18px; height: 28px; background: #ffffff; border: 2px solid var(--ink); }
.knobstrip .knob.plw .k { flex-direction: column; align-items: flex-start; gap: 3px; }
.knobstrip .knob.plw .k b { font-size: 11px; max-width: 100%; white-space: nowrap; }
.knobstrip .knob .k > b { flex: none; }
.knobstrip .knobs:has(> .knob.plw) { align-items: end; }
.knobstrip .knob.choice { grid-column: 1 / -1; gap: 4px; }
.knobstrip .knob .opts { display: flex; flex-wrap: wrap; gap: 4px; }
.knobstrip .knob .opts button { min-height: 30px; padding: 3px 8px; box-shadow: none; }

.pickback { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.pickback[hidden] { display: none; }
.pick { background: var(--panel); border: 2px solid var(--line-hard); box-shadow: 4px 4px 0 var(--slate); width: min(760px, 100%); max-height: min(80vh, 680px); display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.pickhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pickhead h3 { margin: 0; font-weight: 400; text-transform: uppercase; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pickFind { -webkit-user-select: text; user-select: text; background: var(--inset); border: 2px solid var(--line); padding: 7px 8px; border-radius: 0; color: var(--ink); }
.picklist { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; padding: 2px 4px 4px 2px; align-content: start; }
.pgroup { grid-column: 1 / -1; color: var(--muted); text-transform: uppercase; margin: 8px 0 2px; }
.pgroup:first-child { margin-top: 0; }
.picklist button { text-align: left; min-height: 30px; padding: 3px 8px; box-shadow: none; border-color: var(--line); font-family: var(--f-sans); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.picklist button[aria-pressed="true"] { border-color: var(--lit-bg); }
.picklist .pnote { grid-column: 1 / -1; color: var(--muted); padding: 4px 0; }

@media (max-width: 560px) {
  .app { padding: 10px 16px 32px; }
  .trk { flex-wrap: wrap; }
  .tname { flex: 1 1 0; }
  .snd { order: 5; flex: 1 1 100%; }
  .knobstrip .knobs { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
  .transport .row:first-child { flex-wrap: wrap; }
  #seek { flex: 1 1 100%; order: 3; height: 44px; }
  .snd .which { margin: 0 6px; }
  #wavBtn { margin-left: 0; }
  input[type=range] { width: 100px; }
}
