:root {
  --bg: #1b1c1f;
  --bar: #101113;
  --line: #2c2e33;
  --text: #e9e9ea;
  --dim: #9a9ca3;
  --amber: #ffb224;
  --red: #ff2d46;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit; color: var(--text); background: #26282d; border: 1px solid #3a3d44; border-radius: 6px;
  padding: 5px 11px; cursor: pointer; white-space: nowrap;
}
button:hover { background: #30333a; }
button.primary { background: #c8551b; border-color: #e06a2c; font-weight: 600; }
button.primary:hover { background: #dc6424; }
button.on { border-color: var(--amber); color: #ffd98a; }
input[type=number] {
  font: inherit; width: 82px; background: #17181b; color: var(--text); border: 1px solid #3a3d44; border-radius: 6px; padding: 5px 7px;
}

/* ---- top bars ---------------------------------------------------------------- */
header, #composer {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--bar); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .14em; font-size: 13px; }
.brand small { display: block; font-weight: 400; letter-spacing: .04em; color: var(--dim); font-size: 11px; }
.spacer { flex: 1; }
#power .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5a1a22; margin-right: 6px; vertical-align: 1px; }
#power.on .dot { background: var(--red); box-shadow: 0 0 8px 1px var(--red); }
#scope { background: #07090a; border: 1px solid var(--line); border-radius: 6px; display: block; }
.hint { color: var(--dim); font-size: 11.5px; }

#composer { align-items: stretch; }
#composer .col { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
#composer .rowc { display: flex; gap: 8px; align-items: center; }
#piece { min-width: 190px; }
#piece b { font-size: 14px; }
#piece div { color: var(--dim); font-size: 11.5px; }
#now { color: #ffd98a; font-size: 12px; min-height: 17px; }
#perf { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 5px; justify-content: center; }
#timeline { position: relative; display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: #17181b; border: 1px solid var(--line); }
#timeline .seg { font-size: 10.5px; line-height: 20px; text-align: center; color: var(--dim); border-right: 1px solid var(--line); overflow: hidden; white-space: nowrap; }
#timeline .seg.cur { background: #3a2a12; color: #ffd98a; }
#timeline .seg.done { background: #1f2024; }
#cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--amber); left: 0; box-shadow: 0 0 6px var(--amber); display: none; }
#log {
  width: 390px; max-width: 100%; height: 76px; overflow: hidden; background: #07090a; border: 1px solid var(--line); border-radius: 6px;
  font: 10.5px/12.2px Consolas, "Cascadia Mono", monospace; color: #9fd49f; padding: 3px 7px; display: flex; flex-direction: column; justify-content: flex-end;
}
#log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log .n { color: #ffd98a; }
#log .t { color: #5f6570; }

/* ---- rack ---------------------------------------------------------------------- */
#rack { padding: 8px 4px 0; overflow: auto; }
.sizer { margin: 0 auto; overflow: hidden; }
.stage { transform-origin: 0 0; width: max-content; }
.rack { position: relative; display: flex; flex-direction: column; gap: 10px; width: max-content; user-select: none; -webkit-user-select: none; }
.rack.side { flex-direction: row; }

.system {
  background: linear-gradient(#0a0a0b, #050505);
  padding: 9px 13px; border-radius: 7px;
  box-shadow: inset 0 0 0 1px #262626, inset 0 0 0 4px #0c0c0c, 0 6px 18px rgba(0, 0, 0, .55);
}
.row {
  display: flex;
  border-top: 6px solid #9c9c9c; border-bottom: 6px solid #8a8a8a;
  border-image: repeating-linear-gradient(90deg, #b9b9b9 0 9px, #8d8d8d 9px 10px, #2a2a2a 10px 13px, #8d8d8d 13px 14px) 6;
}
.row + .row { margin-top: 5px; }

.module {
  position: relative; display: flex; flex-direction: column;
  width: calc(var(--cols) * 58px + 12px); height: 276px; padding: 0 5px;
  background: linear-gradient(180deg, #19191a, #0e0e0f 60%, #111112);
  border-left: 1px solid #2d2d2f; border-right: 1px solid #000;
}
.blank { flex: 1; min-width: 0; background: linear-gradient(180deg, #19191a, #0e0e0f); border-left: 1px solid #2d2d2f; display: grid; place-items: center; overflow: hidden; }
.blank span { writing-mode: vertical-rl; transform: rotate(180deg); font: 700 9px/1 "Segoe UI", sans-serif; letter-spacing: .3em; color: #777; white-space: nowrap; }

.mod-title { position: relative; height: 20px; font: 700 9.5px/21px "Segoe UI", sans-serif; letter-spacing: .13em; color: #f4f4f4; text-align: center; white-space: nowrap; }
.mod-title .led { position: absolute; right: 2px; top: 7px; }
.mod-foot { height: 11px; font: 500 6px/11px "Segoe UI", sans-serif; letter-spacing: .12em; color: #6d6d6d; text-align: center; text-transform: uppercase; }

.knobs { position: relative; display: grid; grid-template-columns: repeat(var(--cols), 58px); grid-auto-rows: 58px; }
.ctl { position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 4px; }
label { display: block; font: 600 6.8px/7.6px "Segoe UI", sans-serif; letter-spacing: .05em; color: #dedede; text-align: center; text-transform: uppercase; margin-top: 3px; max-width: 56px; pointer-events: none; }

.knob {
  width: 35px; height: 35px; border-radius: 50%; display: grid; place-items: center; cursor: ns-resize; touch-action: none;
  background: radial-gradient(circle at 50% 30%, #333336, #0b0b0c 68%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .9), 0 0 0 1px #000, inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: box-shadow .12s;
}
.cap {
  position: relative; width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(#dcdcdc, #8b8b8b 12%, #f6f6f6 25%, #9a9a9a 37%, #e2e2e2 50%, #838383 62%, #f0f0f0 75%, #959595 87%, #dcdcdc);
  box-shadow: inset 0 0 3px rgba(0, 0, 0, .7), 0 1px 1px rgba(0, 0, 0, .6);
  transition: transform .05s linear;
}
.cap::after { content: ''; position: absolute; left: 50%; top: 1px; width: 2.6px; height: 11px; margin-left: -1.3px; background: #0c0c0c; border-radius: 1px; }
.knob.stepped .cap { background: conic-gradient(#c9c9c9, #777 12%, #e2e2e2 25%, #858585 37%, #cfcfcf 50%, #707070 62%, #dadada 75%, #808080 87%, #c9c9c9); }

/* a control being moved by the composer / API */
.ctl.auto .knob, .ctl.auto .toggle, .ctl.auto .pushbtn { box-shadow: 0 0 0 2px var(--amber), 0 0 14px 4px rgba(255, 178, 36, .8); }
.ctl.auto > label { color: #ffd98a; }
.stepon.auto { box-shadow: 0 0 0 2px var(--amber), 0 0 10px 3px rgba(255, 178, 36, .8); }

.toggle { position: relative; width: 16px; height: 30px; margin-top: 3px; border-radius: 4px; background: #050505; box-shadow: inset 0 0 0 1px #3a3a3a; cursor: pointer; transition: box-shadow .12s; }
.toggle i { position: absolute; left: 3px; top: 16px; width: 10px; height: 11px; border-radius: 2px; background: linear-gradient(#f2f2f2, #8c8c8c); transition: top .08s; }
.ctl.on .toggle i { top: 3px; }
.ctl-switch label { margin-top: 5px; }

.pushbtn { width: 26px; height: 26px; margin-top: 5px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #7c1a25, #3a0a10); box-shadow: 0 0 0 2px #1d1d1d, 0 2px 3px #000; cursor: pointer; }
.ctl.on .pushbtn { background: radial-gradient(circle at 50% 35%, #ff5468, #b3122a); box-shadow: 0 0 0 2px #1d1d1d, 0 0 10px 2px rgba(255, 45, 70, .7); }
.ctl-button label { margin-top: 7px; }

.led { position: relative; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3d0a10; box-shadow: inset 0 0 1px #000; --v: 0; }
.led::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: #ff3148; opacity: var(--v); box-shadow: 0 0 7px 2px rgba(255, 40, 60, .95); }

.ctl.step { padding-top: 3px; }
.ctl.step .led { position: absolute; left: 4px; top: 3px; }
.ctl.step .knob { width: 33px; height: 33px; }
.ctl.step .cap { width: 24px; height: 24px; }
.stepon { margin-top: 3px; width: 30px; height: 12px; padding: 0; border-radius: 3px; border: 1px solid #000; background: #222; color: #777; font: 700 7px/10px "Segoe UI", sans-serif; cursor: pointer; }
.stepon.on { background: #b3122a; color: #fff; }
.stepon:hover { background: #333; }
.stepon.on:hover { background: #cf1a35; }

.glyph { position: absolute; left: 0; right: 0; top: 46px; text-align: center; font: 300 34px/1 "Segoe UI", sans-serif; color: #5c5c5c; }
.ledstrip { position: absolute; left: 0; right: 0; top: 30px; display: flex; flex-direction: column; gap: 13px; align-items: center; }
.ledrow { display: flex; align-items: center; gap: 6px; width: 40px; }
.ledrow label { margin: 0; }
.mod-out .ledstrip { top: 76px; }

.jacks { margin-top: auto; display: grid; grid-template-columns: repeat(var(--jcols), 1fr); grid-auto-rows: 32px; }
.jack { display: flex; flex-direction: column; align-items: center; cursor: crosshair; touch-action: none; }
.hole {
  width: 17px; height: 17px; border-radius: 50%;
  background: radial-gradient(circle, #000 0 30%, #5d5d5d 33% 42%, #dadada 46% 62%, #787878 66% 100%);
  box-shadow: 0 1px 2px #000;
}
.jack label { margin-top: 2px; font-size: 6.2px; line-height: 7px; white-space: nowrap; }
.jack.out label { background: #e4e4e4; color: #101010; padding: 0 2px; border-radius: 1.5px; }
.jack:hover .hole { box-shadow: 0 0 0 2px #fff; }
.rack.want-in .jack.in .hole, .rack.want-out .jack.out .hole { box-shadow: 0 0 0 2px var(--amber), 0 0 8px 2px rgba(255, 178, 36, .7); }
.rack.want-in .jack.out, .rack.want-out .jack.in { opacity: .35; }

/* ---- cables -------------------------------------------------------------------- */
svg.cables { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 5; }
.cable .shadow { fill: none; stroke: rgba(0, 0, 0, .45); stroke-width: 6.5; stroke-linecap: round; transform: translate(1.5px, 3px); }
.wire { fill: none; stroke-width: 4; stroke-linecap: round; opacity: .86; }
.wire.temp { stroke-dasharray: 7 6; opacity: .85; }
.plug { stroke: #0a0a0a; stroke-width: 2; }
.cable.new .wire { stroke-dasharray: 1; stroke-dashoffset: 1; animation: plug-in .4s ease-out forwards; }
.cable.new .plug { animation: pop .5s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes plug-in { to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(2.6); } 100% { transform: scale(1); } }
.rack[data-cables="dim"] svg.cables { opacity: .28; }
.rack[data-cables="off"] svg.cables { display: none; }

.tip {
  position: fixed; display: none; z-index: 50; pointer-events: none; white-space: nowrap;
  background: #f1f1f1; color: #111; font: 600 11px/1 Consolas, monospace; padding: 5px 7px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}

@media (prefers-reduced-motion: reduce) {
  .cable.new .wire, .cable.new .plug { animation: none; stroke-dashoffset: 0; }
}

@media (max-width: 1250px) {
  .hint:not(#load) { display: none; }
  header, #composer { padding: 6px 10px; gap: 8px; }
  #log { height: 52px; flex: 1; min-width: 240px; }
}
