/* studio skin: charcoal desk, cream legends, one warm accent */

:root {
  --panel: #1b1c21;
  --panel-2: #23242b;
  --panel-3: #2b2d36;
  --rail: #0f1014;
  --ink: #eceae3;
  --cream: #e7e1d2;
  --muted: #8a8d99;
  --line: #34363f;
  --line-soft: #2a2c34;
  --accent: #e8772e;  /* warm orange */
  --teal: #46c6b0;
  --yellow: #f2c14e;
  --mono: "SFMono-Regular", "JetBrains Mono", "Menlo", "Consolas", monospace;
  --sans: "Inter", "Helvetica Neue", "Arial", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--sans);
  background: #0c0d10;
  color: var(--ink);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top transport bar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  /* extra right room so the transport clears the fixed exit chip */
  padding: 12px 132px 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

#sidebar-toggle {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

#sidebar-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
}

#logo {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.brand-word {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f4f4f2 0%, #b9bcc6 45%, #7e838f 55%, #d8dade 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#patch-name {
  flex: 1 1 auto;
  max-width: 360px;
  padding: 7px 12px;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

#patch-name:focus {
  outline: none;
  border-color: var(--accent);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

#transport-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
}

#transport-badge:focus-within {
  border-color: var(--teal);
}

#bpm-input {
  /* 3 digits plus the badge's inherited 0.12em letter-spacing */
  width: calc(3ch + 0.45em);
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: right;
}

#bpm-input:focus {
  outline: none;
}

.bpm-unit {
  color: var(--muted);
}

#transport {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#transport-mark {
  font-size: 13px;
  line-height: 1;
}

/* ---------- app frame ---------- */
#app {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 59px);
}

#sidebar {
  flex: none;
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  transition: width 0.18s ease, padding 0.18s ease;
}

#sidebar.collapsed {
  width: 72px;
  padding-left: 10px;
  padding-right: 10px;
}

#sidebar.collapsed .rack-label {
  display: none;
}

#sidebar.collapsed .preset {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

#sidebar.collapsed .preset-name {
  display: none;
}

#sidebar.collapsed .preset-no {
  opacity: 1;
}

#preset-rack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rack-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.preset {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.preset:hover {
  color: var(--ink);
  border-color: var(--line);
}

/* numbered rack slots, collapsed to the bare number */
.preset-no {
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.preset.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(232, 119, 46, 0.08);
}

#meter {
  position: relative;
  flex: none;
  width: 44px;
  height: 120px;
  border-radius: 4px;
  background: var(--rail);
  border: 1px solid var(--line);
  overflow: hidden;
}

#meter::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /* master fader drives the fill height */
  height: var(--meter-fill, 62%);
  background: linear-gradient(180deg, var(--teal), rgba(70, 198, 176, 0.15));
  opacity: 0.55;
}

#meter-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--cream);
  z-index: 2;
}

.meter-cap {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 2;
}

/* ---------- main desk ---------- */
#content {
  flex: 1 1 auto;
  min-width: 384px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* the session readout: position counter and format line, DAW-style */
#position-readout {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

#session-meta {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* transport timeline: a fixed cue and a draggable playhead */
#transport-zone {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

#timeline {
  position: relative;
  flex: none;
  width: 248px;
  height: 120px;
  border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, transparent 0 30px, var(--line-soft) 30px 31px),
    var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

#timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 156px;
  width: 1px;
  background: repeating-linear-gradient(180deg, var(--line) 0 4px, transparent 4px 8px);
}

#cue {
  position: absolute;
  left: 150px;
  top: 90px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(70, 198, 176, 0.2);
}

#playhead {
  position: absolute;
  left: 170px;
  top: 70px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(232, 119, 46, 0.22);
  cursor: grab;
  touch-action: none;
  z-index: 5;
}

#playhead:active {
  cursor: grabbing;
}

#playhead::after {
  content: "";
  position: absolute;
  inset: -8px;
}

/* the cue's pocket: a dashed target the playhead snaps into */
#cue-target {
  position: absolute;
  left: 164px;
  top: 64px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed rgba(232, 119, 46, 0.55);
  pointer-events: none;
  z-index: 4;
}

/* ---------- mixer row ---------- */
#mixer-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

#desk {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1 1 280px;
  min-width: 240px;
  max-width: 430px;
}

.channel {
  flex: 1 1 0;
  min-width: 0;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 14px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
}

/* master bus: the sum rail, prominent above the mixer */
.channel.master {
  flex: none;
  flex-direction: row;
  align-items: center;
  gap: 18px;
  height: auto;
  min-height: 0;
  padding: 14px 18px;
  background: var(--panel-2);
  border-color: var(--line);
}

.channel.master .strip-handle {
  width: auto;
  flex: none;
  padding: 0;
  border-bottom: none;
  cursor: default;
  color: var(--ink);
  letter-spacing: 0.18em;
}

.channel.master .knob {
  width: 56px;
  flex: none;
}

.channel.master .knob {
  border-color: #c9a24f;
  box-shadow: inset 0 0 0 1px rgba(201, 162, 79, 0.45);
}

#master-gain .knob-pointer {
  background: #e4c069;
}

.strip .knob {
  border-color: #6f7480;
  box-shadow: inset 0 0 0 1px rgba(160, 166, 178, 0.28);
}

.master-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
  min-width: 42px;
}

.master-cap {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.master-bar {
  position: relative;
  flex: 1 1 auto;
  height: 14px;
  border-radius: 3px;
  background: var(--rail);
  border: 1px solid var(--line);
  overflow: hidden;
}

.master-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(90deg, rgba(232, 119, 46, 0.3), var(--accent));
}

.strip-handle {
  width: 100%;
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

/* per-channel identity: led and knob pointer share a colour */
.ch-led {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
  background: var(--led, var(--muted));
  box-shadow: 0 0 6px var(--led, transparent);
}

#strip-1 {
  --led: var(--accent);
}
#strip-2 {
  --led: var(--yellow);
}

#strip-1 .knob-pointer {
  background: var(--accent);
}
#strip-2 .knob-pointer {
  background: var(--yellow);
}

.channel.dragging {
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}

.channel.dragging .strip-handle {
  cursor: grabbing;
}

/* knobs: real rotary affordances */
.knob {
  position: relative;
  width: 42px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--panel-3), #15161b 80%);
  border: 1px solid var(--line);
  touch-action: none;
  cursor: ns-resize;
}

.knob-dial {
  position: absolute;
  inset: 0;
  transform: rotate(var(--angle, 0deg));
}

.knob-pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  background: var(--cream);
  border-radius: 1px;
}

/* faders: drag to set level */
.fader {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
}

.fader-rail {
  position: relative;
  width: 12px;
  border-radius: 3px;
  background: var(--rail);
  border: 1px solid var(--line);
  touch-action: none;
  cursor: ns-resize;
}

.fader-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(180deg, var(--accent), rgba(232, 119, 46, 0.25));
}

.fader-cap {
  position: absolute;
  left: 50%;
  width: 30px;
  height: 12px;
  margin-left: -15px;
  border-radius: 3px;
  background: var(--cream);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  transform: translateY(50%);
}

.ch-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ---------- pad grid ---------- */
#pads {
  flex: none;
  width: 300px;
  height: 300px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
}

/* silk-screen bank strip inside the pad module */
#pads::before {
  content: "pattern · bank a";
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}

.pad {
  position: relative;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.08s ease, border-color 0.08s ease;
}

.pad-key {
  position: absolute;
  left: 7px;
  bottom: 5px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}

.pad.lit .pad-key {
  color: rgba(15, 16, 20, 0.75);
}

.pad:hover {
  border-color: var(--muted);
}

.pad.lit {
  background: rgba(232, 119, 46, 0.85);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(232, 119, 46, 0.5);
}

/* overload light, hidden until a fader is pushed into the red */
#clip-light {
  position: fixed;
  top: 70px;
  right: 22px;
  z-index: 40;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff2ef;
  background: #d3352b;
  box-shadow: 0 0 12px rgba(211, 53, 43, 0.6);
  padding: 5px 10px;
  border-radius: 4px;
}

#clip-light.is-hidden {
  display: none;
}



/* ---------- silk-screen labels under the rotaries ---------- */
.knob-cap {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- machine patchbay ---------- */
#machine-rack {
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

#machine-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#machine-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.mk-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 5px rgba(70, 198, 176, 0.6);
}

#machine-list li:nth-child(2) .mk-led {
  background: var(--accent);
  box-shadow: 0 0 5px rgba(232, 119, 46, 0.6);
}

.mk-role {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

#sidebar.collapsed .mk-role,
#sidebar.collapsed .mk-name {
  display: none;
}

#sidebar.collapsed #machine-list li {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* ---------- fx send ---------- */
#fx-rack {
  flex: 1 1 280px;
  min-width: 230px;
  max-width: 360px;
  height: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.fx-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}

.fx {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  cursor: pointer;
}

.fx-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line);
}

.fx.on {
  color: var(--ink);
  border-color: var(--line);
}

.fx.on .fx-led {
  background: #d3352b;
  box-shadow: 0 0 5px rgba(211, 53, 43, 0.7);
}

.fx-knobs {
  display: flex;
  justify-content: space-around;
  padding: 6px 0 4px;
}

.fx-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.knob.mini {
  width: 34px;
}

/* ---------- responsive: fx bar below 1090px, full stack below 842px ---------- */
@media (max-width: 1089px) {
  #mixer-row {
    flex-wrap: wrap;
  }

  /* wrap fits lines by basis, so the basis must equal the desk minimum */
  #desk {
    flex-basis: 240px;
  }

  #fx-rack {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
  }

  #fx-rack .fx-label {
    border-bottom: none;
    padding-bottom: 0;
    flex: none;
  }

  #fx-rack .fx-knobs {
    flex: none;
    gap: 16px;
    padding: 0;
  }
}

@media (max-width: 841px) {
  #desk {
    flex: 1 1 100%;
    max-width: none;
  }

  #pads {
    margin: 0 auto;
  }
}
