:root {
 --bg: #06090c;
 --fg: #cfe0ec;
 --dim: #728da0;
 --edge: #2c3d48;
 --mid: #9ab0bd;
 --hot: #ffffff;
 --note: #47e08a;
 --cyan: #35d8ff;
 --amber: #ffb000;
 --violet: #c78bff;
 --red: #ff4d4d;
 --ghost: #556a78;
 --line: #16222a;
 --gap: 10px;
 --pad: 14px;
 --mono: 13px;
 --grid: 12px;
 --list: 18vh;
}

* {
 box-sizing: border-box;
}

html, body {
 height: 100%;
}

body {
 margin: 0;
 background: var(--bg);
 color: var(--fg);
 font-family: "DejaVu Sans Mono", "Liberation Mono", Consolas, monospace;
 font-size: var(--mono);
 line-height: 1.35;
 overflow: hidden;
 -webkit-text-size-adjust: 100%;
}

#shell {
 height: 100%;
 height: 100dvh;
 display: flex;
 flex-direction: column;
 padding: var(--pad);
 gap: var(--gap);
}

#logo {
 margin: 0;
 color: var(--hot);
 font-size: 12px;
 line-height: 1.1;
 white-space: pre;
 overflow: hidden;
}

#logo::first-line {
 color: var(--fg);
}

#deck {
 flex: 1;
 display: flex;
 gap: var(--gap);
 min-height: 0;
}

#left {
 width: 430px;
 display: flex;
 flex-direction: column;
 gap: var(--gap);
 min-height: 0;
}

#right {
 flex: 1;
 display: flex;
 flex-direction: column;
 min-height: 0;
 min-width: 0;
 border: 1px solid var(--edge);
}

#screen, #playlist, #samples, #transport, #vu {
 border: 1px solid var(--edge);
}

#screen {
 padding: 8px 10px;
}

#screen .row {
 display: flex;
 gap: 10px;
 white-space: nowrap;
 overflow: hidden;
}

#screen .key {
 flex: 0 0 62px;
 color: var(--dim);
}

#screen .val {
 color: var(--hot);
 overflow: hidden;
 text-overflow: ellipsis;
}

#scope {
 display: block;
 width: 100%;
 height: 96px;
 border: 1px solid var(--edge);
 background: #04090d;
}

#vu {
 display: flex;
 align-items: flex-end;
 gap: 2px;
 height: 46px;
 padding: 4px;
}

#vu .bar {
 flex: 1;
 min-width: 3px;
 height: 100%;
 background: var(--edge);
 position: relative;
}

#vu .bar i {
 position: absolute;
 bottom: 0;
 left: 0;
 right: 0;
 height: 0;
 background: var(--note);
}

#transport {
 display: flex;
 align-items: center;
 gap: 6px;
 padding: 6px;
}

button {
 flex: 0 0 auto;
 min-width: 46px;
 min-height: 34px;
 padding: 5px 8px;
 background: #0c161d;
 color: var(--fg);
 border: 1px solid var(--mid);
 font: inherit;
 cursor: pointer;
 touch-action: manipulation;
}

button:active, button.on {
 background: var(--mid);
 color: #05121a;
 text-shadow: none;
}

#gain {
 flex: 1;
 min-width: 60px;
 accent-color: var(--cyan);
}

#playlist {
 flex: 1;
 margin: 0;
 padding: 2px;
 list-style: none;
 overflow-y: auto;
 min-height: 0;
 -webkit-overflow-scrolling: touch;
}

/* Both lists share one metric so they can never drift apart */
#playlist li, #samples li {
 padding: 1px 6px;
 font-size: var(--mono);
 line-height: 1.08;
}

#playlist li {
 color: var(--mid);
 cursor: pointer;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}

#playlist li.on {
 color: #05121a;
 background: var(--cyan);
 text-shadow: none;
}

#samples {
 flex: 1;
 margin: 0;
 padding: 2px;
 list-style: none;
 overflow: auto;
 min-height: 0;
 white-space: pre;
 -webkit-overflow-scrolling: touch;
}

#samples li {
 color: var(--dim);
}

#samples li.live {
 color: var(--cyan);
}

#samples li.hit {
 color: var(--hot);
}

#patternview {
 flex: 1;
 overflow: auto;
 min-height: 0;
 -webkit-overflow-scrolling: touch;
 overscroll-behavior: contain;
}

#logo {
 color: var(--hot);
}

#patternhead {
 position: sticky;
 top: 0;
 z-index: 1;
 width: max-content;
 min-width: 100%;
 padding: 3px 8px;
 border-bottom: 1px solid var(--edge);
 background: var(--bg);
 color: var(--dim);
 white-space: pre;
 font-size: var(--grid);
}

#pattern {
 width: max-content;
 min-width: 100%;
 margin: 0;
 padding: 2px 8px 8px;
 font-size: var(--grid);
 line-height: 1.08;
 white-space: pre;
 color: var(--mid);
}

#pattern b {
 display: block;
 font-weight: normal;
}

#pattern i {
 font-style: normal;
}

#pattern .r { color: var(--dim); }
#pattern .n { color: var(--note); }
#pattern .s { color: var(--cyan); }
#pattern .v { color: var(--amber); }
#pattern .e { color: var(--violet); }
#pattern .z { color: var(--ghost); }

#pattern b.beat {
 background: #101b22;
}

#pattern b.beat .r {
 color: var(--mid);
}

/* The playing row inverts, the column colours give way to contrast */
#pattern b.cur {
 background: var(--cyan);
}

#pattern b.cur i {
 color: #05121a;
 text-shadow: none;
}

::-webkit-scrollbar {
 width: 8px;
 height: 8px;
}

::-webkit-scrollbar-track {
 background: #0c141a;
}

::-webkit-scrollbar-thumb {
 background: var(--edge);
}

/* Pointer devices get hover feedback, touch devices keep the pressed state only */
@media (hover: hover) {
 button:hover {
  background: #18262f;
  color: var(--hot);
 }

 #playlist li:hover {
  color: var(--hot);
  background: #18262f;
 }

 ::-webkit-scrollbar-thumb:hover {
  background: var(--mid);
 }
}

/* Narrow viewports stack the deck and let the shell scroll */
@media (max-width: 900px) {
 body {
  overflow: auto;
 }

 #shell {
  height: auto;
  min-height: 100dvh;
  padding: 10px;
 }

 #deck {
  flex-direction: column;
 }

 #left {
  width: 100%;
 }

 #playlist, #samples {
  flex: none;
  max-height: var(--list);
 }

 #right {
  flex: none;
  height: 46vh;
 }

 #scope {
  height: 72px;
 }
}

/* Phones drop the ornaments and grow the touch targets */
@media (max-width: 560px) {
 :root {
  --mono: 12px;
  --grid: 11px;
  --gap: 8px;
 }

 #logo {
  font-size: 9px;
 }

 #transport {
  flex-wrap: wrap;
 }

 #transport button {
  flex: 1 1 0;
  min-height: 44px;
 }

 #gain {
  flex: 1 0 100%;
  min-height: 28px;
 }

 #screen .key {
  flex-basis: 52px;
 }

 #vu {
  height: 34px;
 }

 #right {
  height: 40vh;
 }
}

/* Landscape phones keep the two columns but shrink the left rail */
@media (max-height: 480px) and (orientation: landscape) {
 #logo {
  display: none;
 }

 #deck {
  flex-direction: row;
 }

 #left {
  width: 300px;
 }

 #right {
  flex: 1;
  height: auto;
 }

 #scope {
  height: 56px;
 }

 #playlist, #samples {
  flex: 1;
  max-height: none;
 }
}
