:root { --hpw: 16px; --modh: 380px; color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: #16171a; color: #ddd; font: 14px/1.4 system-ui, sans-serif; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; background: #0e0f11; border-bottom: 1px solid #2a2c30; }
.top h1 { margin: 0; font: 800 22px/1 ui-monospace, monospace; letter-spacing: 3px; color: #f2b632; }
.top h1 small { font-weight: 400; font-size: 12px; letter-spacing: 1px; color: #888; margin-left: 6px; }
.vol { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.vol small, .people, .status { color: #888; }
.status { color: #f07f3c; }

.btn { font: 600 12px/1 system-ui, sans-serif; color: #ddd; background: #26282d; border: 1px solid #3a3d44; border-radius: 5px; padding: 7px 10px; cursor: pointer; }
.btn:hover { background: #30333a; }
.btn.hot { background: #f2b632; color: #111; border-color: #f2b632; font-size: 14px; padding: 9px 14px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; background: #121316; border-bottom: 1px solid #2a2c30; }
.btn.add { border-left: 4px solid var(--accent); }
.btn.reset { margin-left: auto; color: #e5484d; }

/* Rack: rows of rails, modules in a row by HP width. */
.wrap { position: relative; padding: 14px; }
.rack {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0; min-height: calc(var(--modh) + 24px);
  background: repeating-linear-gradient(#0c0c0d 0 12px, #2b2d31 12px 14px, #0c0c0d 14px calc(var(--modh) - 2px), #2b2d31 calc(var(--modh) - 2px) var(--modh), #0c0c0d var(--modh) calc(var(--modh) + 12px));
}
.cables { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.cable path { fill: none; stroke-width: 5; stroke-linecap: round; opacity: 0.85; }
.cable path.glow { stroke-width: 16; opacity: 1; }
.cable path.sh { stroke: #000; stroke-width: 8; opacity: 0.35; }
.cable circle { opacity: 0.95; }
.cable.drag path { opacity: 1; }

.mod {
  position: relative; width: calc(var(--hp) * var(--hpw)); height: var(--modh); margin: 0 0 12px; padding: 0 6px 8px;
  display: flex; flex-direction: column;
  background: linear-gradient(90deg, #b9bcc1, #d9dbde 30%, #c7c9cd 70%, #aeb1b6); color: #1b1c1f;
  border-left: 1px solid #e8e9eb; border-right: 1px solid #6b6e74; user-select: none;
}
.mod::before, .mod::after { content: ""; position: absolute; left: 7px; width: 7px; height: 7px; border-radius: 50%; background: #7d8087; box-shadow: inset 1px 1px 1px #000; }
.mod::before { top: 4px; } .mod::after { bottom: 4px; }
.mod.lifted { opacity: 0.5; }
.mod.drop-l { box-shadow: inset 4px 0 0 #f2b632; }
.mod.drop-r { box-shadow: inset -4px 0 0 #f2b632; }

.head { display: flex; align-items: center; justify-content: center; margin: 14px -6px 6px; padding: 4px 6px; background: var(--accent); position: relative; }
.name { font: 800 12px/1 ui-monospace, monospace; letter-spacing: 1.5px; cursor: grab; padding: 2px 4px; touch-action: none; }
.del { position: absolute; right: 2px; top: 1px; border: 0; background: none; color: #0007; font-size: 12px; cursor: pointer; padding: 2px 4px; }
.del:hover { color: #000; }

.body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; overflow: hidden; }
.knobs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 2px; }
.ctl { display: flex; flex-direction: column; align-items: center; width: 40px; }
.ctl.small { width: 32px; }
.lbl { font: 700 9px/1.2 ui-monospace, monospace; letter-spacing: 0.5px; text-align: center; }
.val { font: 9px/1.2 ui-monospace, monospace; color: #444; min-height: 11px; white-space: nowrap; }
.ctl.small .val { font-size: 8px; }
.knob { width: 38px; height: 38px; border-radius: 50%; touch-action: none; cursor: ns-resize;
  background: radial-gradient(circle at 35% 30%, #4a4c52, #121214 70%); box-shadow: 0 2px 3px #0008, 0 0 0 3px #9a9da3; }
.ctl.small .knob { width: 26px; height: 26px; box-shadow: 0 1px 2px #0008, 0 0 0 2px #9a9da3; }
.cap { width: 100%; height: 100%; }
.cap::after { content: ""; display: block; width: 3px; height: 38%; margin: 2px auto 0; background: #f4f4f4; border-radius: 2px; }
.ctl.active .knob { box-shadow: 0 0 0 3px var(--accent); }
.btn.opt { padding: 5px 6px; font: 700 10px/1 ui-monospace, monospace; background: #1b1c1f; min-width: 46px; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; padding-top: 4px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tog { width: 22px; height: 14px; border-radius: 3px; border: 1px solid #555; background: #3a3c40; cursor: pointer; padding: 0; }
.tog.on { background: #f2b632; box-shadow: 0 0 6px #f2b632; }
.led { display: block; width: 8px; height: 8px; border-radius: 50%; background: #4a1f1f; box-shadow: inset 0 0 2px #000; }
.led.on { background: #ff4a3d; box-shadow: 0 0 8px #ff4a3d; }
.led.off { opacity: 0.25; }
.dleds { display: grid; grid-template-columns: repeat(8, 8px); gap: 5px; }
.btn.dice { background: #1b1c1f; font-size: 11px; }
.scr { width: 100%; border-radius: 3px; border: 2px solid #333; }

.jacks { display: flex; flex-direction: column; gap: 6px; }
.ins, .outs { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 2px; padding: 4px 2px; border-radius: 4px; }
.outs { background: #2a2c30; color: #ddd; }
.jack { display: flex; flex-direction: column; align-items: center; width: 36px; }
.hole { width: 24px; height: 24px; border-radius: 50%; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle, #050505 0 34%, #7f8288 36% 50%, #d2d4d8 54% 70%, #8a8d93 72%); }
.hole:hover { box-shadow: 0 0 0 2px #f2b632; }
.jack.k-gate .lbl { color: #b5651d; } .outs .jack.k-gate .lbl { color: #f2b632; }
.jack.k-cv .lbl { color: #1f5f8a; } .outs .jack.k-cv .lbl { color: #6cc4ff; }

.help { max-width: 900px; padding: 4px 16px 24px; color: #888; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #e5484d; color: #fff; padding: 8px 14px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 600px) { :root { --hpw: 14px; } .top h1 { font-size: 18px; } }
