:root {
  --bg: #15171a; --panel: #1d2024; --panel2: #252a30; --line: #343a42; --text: #dfe3e8; --dim: #8b95a1;
  --accent: #5aa9ff; --focus: #ffd24a; --on: #4cc38a; --danger: #e5645a;
  --c-gate: #4cc38a; --c-pitch: #5aa9ff; --c-vel: #e0a64a; --c-cc: #c77dff;
  --grey: #6b7480;
  color-scheme: dark;
}
/* (the app is dark only, whatever the device is set to: everything is styled for it, SPEC 2.223) */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.35 system-ui, sans-serif; }
button, select, input { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.on, button.part.on { background: var(--accent); border-color: var(--accent); color: #fff; }
button.play.on { background: var(--danger); border-color: var(--danger); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .spacer, .lane-head .spacer { flex: 1; }
.tempo { display: flex; gap: 6px; align-items: center; color: var(--dim); }
input.bpm { width: 70px; }
.undo-label { color: var(--dim); font-size: 12px; }
button.midi.ok { color: var(--on); }
nav.tabs { display: flex; gap: 6px; align-items: center; padding: 8px 16px 0; }
nav.tabs .page { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }
button.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
nav.tabs .sep { color: var(--dim); }
button.tab.page-tab { font-weight: 600; }
.context { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px 0; }
.context .spacer { flex: 1; }
.clabel { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
input.dur { width: 70px; }
.tcontrols { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tcontrols select { max-width: 120px; }
.addlane { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
main { padding: 12px 16px 70px; display: flex; flex-direction: column; gap: 16px; }
.track { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.track > header { display: flex; gap: 8px; align-items: center; padding: 6px 12px; background: var(--panel2); }
.track > header .spacer { flex: 1; }
.track h2 { margin: 0; font-size: 15px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--bg); color: var(--dim); border: 1px solid var(--line); white-space: nowrap; }
.badge.dim { opacity: .7; }
.lane { border-top: 1px solid var(--line); }
.lane.focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.lane.hidden-lane { opacity: .45; }
.lane-head { display: flex; gap: 8px; align-items: center; padding: 4px 12px; min-height: 34px; cursor: pointer; }
.lane-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lane-head .name { font-weight: 600; min-width: 4.5em; }
button.part { padding: 1px 8px; line-height: 1.4; }
.params { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 6px 12px 10px; background: var(--bg); border-top: 1px dashed var(--line); }
.group { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; }
.gname { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.field { display: flex; gap: 5px; align-items: center; }
.field span { color: var(--dim); font-size: 12px; }
.field input[type=number] { width: 62px; }
.note-text { padding: 6px 12px; color: var(--dim); font-size: 12px; }
.preview, .editor { padding: 4px 12px 8px; }
.grid { width: 100%; }
.grid-body { position: relative; display: flex; flex-direction: column; gap: 2px; }
.row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 1px; }
.cell { position: relative; height: 26px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; user-select: none; touch-action: none; }
.cell.beat { border-left-color: var(--dim); }
.cell.cursor, .col.cursor { outline: 2px solid var(--focus); outline-offset: -1px; z-index: 2; }
.ro .cell { height: 10px; border-color: transparent; background: color-mix(in srgb, var(--bg) 70%, var(--line)); }
.note { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--c-gate); border-radius: 2px; z-index: 1; min-width: 4px; }
.ro .note { top: 1px; bottom: 1px; }
.note.off { width: 8px; background: transparent; border: 2px solid var(--c-gate); }
.grid-pitch .txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--c-pitch); font-variant-numeric: tabular-nums; }
.ro .txt { display: none; }
.ro.grid-pitch .cell.set { background: var(--c-pitch); }
.bars { height: 90px; align-items: stretch; }
.ro .bars { height: 36px; }
.col { position: relative; display: flex; align-items: flex-end; gap: 1px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; touch-action: none; user-select: none; }
.col.beat { border-left-color: var(--dim); }
.bar { flex: 1; min-width: 2px; background: var(--c-vel); border-radius: 1px 1px 0 0; }
.grid-bars .bar { background: var(--c-vel); }
.bar.cursor { background: var(--focus); }
.loop { position: absolute; top: -3px; height: 3px; background: var(--accent); opacity: .6; }
.playhead { position: absolute; top: 0; bottom: 0; background: rgba(255,255,255,.14); border-left: 2px solid #fff; pointer-events: none; display: none; z-index: 3; }
.status { position: fixed; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 6px 24px; padding: 6px 16px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; z-index: 5; }
.status .where { color: var(--focus); font-weight: 600; }
.status .hints { color: var(--dim); }
.status .msg { color: var(--danger); }
@media (max-width: 560px) { .topbar { padding: 6px 8px; } main { padding: 8px; } .lane-head .badge.gen { display: none; } }

/* --- module strip (prototype) --- */
.strip { position: relative; }
.strip-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin-bottom: 8px; }
.hintline { color: var(--dim); font-size: 12px; }
.buses { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.blabel { color: var(--dim); font-size: 12px; margin-right: 4px; }
button.bus { border-color: hsl(300 40% 40%); color: hsl(300 60% 75%); border-radius: 12px; padding: 1px 10px; }
.chain { scrollbar-width: none; display: flex; gap: 6px; align-items: stretch; overflow-x: auto; padding-bottom: 10px; cursor: grab; user-select: none; }
.chain::-webkit-scrollbar { display: none; }
.chain.panning { cursor: grabbing; }
.chain .mod { transition: transform .15s ease; }
.chain .mod.dragging { transition: none; }
.mhead { cursor: grab; touch-action: none; }
.mod.dragging { z-index: 20; opacity: .85; box-shadow: 0 8px 24px rgba(0,0,0,.5); cursor: grabbing; }
.tu-group.lgroup { position: relative; box-sizing: border-box; min-width: 0; min-height: 0; pointer-events: none; }
.tu-group.lgroup > .tu-grouptitle { position: absolute; top: calc(var(--u) * .2); left: 0; right: 0; }
/* the Echo: its widgets are 46 u wide and a module is as wide as a multiple of 4 u (see fit): one more u in the slots makes 47 u in 48, a half u of space on each side as in the Turing module */
.mod[data-type="echo"] .ins:has(> :nth-child(7)) { min-width: calc(var(--u) * 15); }
.b-icon { display: block; color: var(--text); overflow: visible; }
.mresize { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; z-index: 6; cursor: ew-resize; touch-action: none; }
.mresize:hover { background: color-mix(in srgb, var(--c) 45%, transparent); }
.mod { position: relative; flex: none; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 6px; }
.mod.msel { outline: 2px solid var(--focus); outline-offset: 1px; }
.mhead { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 4px 8px; background: color-mix(in srgb, var(--c) 18%, var(--panel)); }
.mtitle { font-weight: 600; }
.mrole { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.mbody { position: relative; display: flex; gap: 6px; padding: 8px 6px; flex: 1; }
/* the slots area and the knobs fill the fixed height of the module body from the top down and then start a new column */
.ins { display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: var(--w-gap); height: var(--w-body); }
.kbreak { flex: 0 0 100%; width: 0; }
/* the outputs appear only in connect mode, as a panel over the card so nothing moves */
/* the output slots of a module, while a connection is made: an overlay over the slots area at the right of the body, as high as the slots area and in line with it (the header stays visible); it covers what is below and never resizes the module; thin border on its left; columns of slots from the right */
.outs { position: absolute; top: 8px; right: 0; z-index: 5; box-sizing: border-box; padding: 0 6px 0 0; height: var(--w-body); background: var(--panel2); border-left: 1px solid var(--line); box-shadow: -6px 0 12px rgba(0,0,0,.3); }
.outcols { display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; height: var(--w-body); }
.outs[hidden] { display: none; }
/* the overlay of the outputs stops where the column of the rows of a MIDI in begins; the column looks like the overlay while outputs are picked */
.mod .outs { right: var(--rows-w, 0px); }
.ins.rowscol { flex: none; align-self: flex-start; box-sizing: border-box; margin: calc(var(--u) * -1) 0; padding: calc(var(--u) * 1) 0; height: calc(var(--w-body) + var(--u) * 2); }
/* a module with fields (device, channel) is as wide as its grid units: what is left over after its slots goes to the fields */
.mbody > .cols:has(> .mid > .band) { align-self: stretch; }
.cols > .mid:has(> .band) { flex: 1; }
/* the output slots of a module as a column of their own at its right (SPEC 2.126) */
.ins.outscol { flex: none; align-self: flex-start; box-sizing: border-box; margin: calc(var(--u) * -1) 0; padding: calc(var(--u) * 1) 0; height: calc(var(--w-body) + var(--u) * 2); border-left: 1px solid var(--line); }
.strip:not(.connecting) .outscol .sock.out { opacity: 1; cursor: context-menu; }
.rowscol.asouts { background: var(--panel2); border-left: 1px solid var(--line); }
.sock.out:not(.cand) { opacity: .45; cursor: default; }
.knobs { display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: var(--w-gap); height: var(--w-body); padding: 0 6px; }
.pubrow { display: flex; gap: 2px; align-items: center; }
.chain input { user-select: text; cursor: text; }
input.pubinput { box-sizing: border-box; width: calc(var(--u) * 13); height: calc(var(--u) * 3); padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * 1.4); }
.outname { color: var(--dim); }
.editor-preview { margin-top: 10px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.editor-preview .dim { color: var(--dim); font-size: 12px; }
.etitle { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.erow { display: flex; gap: 8px; align-items: center; margin: 2px 0; }
.ename { width: 7em; font-size: 12px; color: var(--dim); }
.ecells { position: relative; flex: 1; height: 16px; background-color: var(--bg); border: 1px solid var(--line); background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: calc(100% / var(--n)) 100%; }
.ewin { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 28%, transparent); pointer-events: none; }
.erep { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--dim) 25%, transparent) 4px 8px); pointer-events: none; }
.eres { width: 4.5em; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.mid { display: flex; flex-direction: column; gap: 4px; }
.w-cell.choice { cursor: pointer; }
.kgroup { display: flex; flex-direction: column; flex: none; }
button.bus svg { vertical-align: -2px; margin-right: 5px; }
.sock:not(.w-cell) { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--dim); cursor: pointer; padding: 1px 3px; border-radius: 9px; }
.sock:not(.w-cell) .dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--dim); flex: none; }
.sock.sel:not(.w-cell) { outline: 2px solid var(--focus); outline-offset: 1px; }
.w-cell.sock { cursor: pointer; }
.strip.connecting .mod { opacity: .55; }
.strip.connecting .mod:has(.cand), .strip.connecting .mod.from { opacity: 1; }
.sock.out.cand:not(.w-cell), button.bus.cand { opacity: 1; color: var(--text); background: color-mix(in srgb, var(--focus) 22%, transparent); outline: 1px solid var(--focus); }
/* (the output the keyboard would pick has no frame: no cursor markers, SPEC 2.23) */
.sock.cur .dot, button.bus.cur, .sock.in.active .dot, .w-cell.active .w-dot { animation: blink 0.9s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.popup .ptitle.closable, .rackmenu .ptitle.closable { padding-right: 26px; }
.popup .pclose, .rackmenu .pclose { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; padding: 0; min-height: 0; line-height: 1; font-size: 12px; color: var(--dim); background: transparent; border: 0; cursor: pointer; }
.popup .pclose:hover, .rackmenu .pclose:hover { color: var(--text); }
.psubwrap { display: flex; flex-direction: column; }
.popup.flyout { display: none; position: fixed; z-index: 20; min-width: 14em; top: 0; left: 0; }
.psubwrap.open > .popup.flyout { display: flex; }
.popup { overflow-y: auto; position: absolute; z-index: 10; top: 80px; left: 20px; min-width: 260px; background: var(--panel2); border: 1px solid var(--accent); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.ptitle { padding: 2px 8px; color: var(--dim); font-size: 11px; text-transform: uppercase; }
button.pitem { text-align: left; border-color: transparent; background: transparent; }
/* the two columns of a menu (SPEC 2.111): the label, and at the right what it stands at (a value, a field to pick from, ▸ for a submenu) */
.pitem.prow { display: flex; align-items: center; gap: 16px; }
.pitem.prow .plabel { flex: 1 1 auto; }
.pitem.prow .pvalue { flex: none; min-width: 3em; text-align: right; color: var(--dim); }
.pitem.prow.on .pvalue { color: inherit; }
/* a switch in a menu (SPEC 2.116): a check mark while it is on, nothing while it is off */
.pitem.prow .pvalue.pcheck.on { color: var(--text); }
.pitem.pchoice { padding: 4px 6px 4px 8px; border: 1px solid transparent; border-radius: 4px; }
.pselect { flex: none; max-width: 14em; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.psep { flex: none; height: 1px; margin: 3px 4px; background: color-mix(in srgb, var(--dim) 35%, var(--line)); } /* (flex: none, SPEC 2.133: in a long menu, which is a column of limited height, the line shrank to 0 px) */
button.pitem.on { background: var(--accent); color: #fff; }
/* the item under the mouse (SPEC 2.132: no item is lit when a menu opens): a light tint, the lines between the groups stay seen */
.popup button.pitem:hover:not(:disabled), .rackmenu button.pitem:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 22%, transparent); }
/* a name typed in the menu itself (SPEC 2.110): the label in front, the field after it */
.pinput-row { padding: 2px 8px; }
.pinput-label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
/* an entry field in a menu (SPEC 2.121): a dark grey background, so it is seen as a field to type in */
.pinput { flex: 1; min-width: 8em; font: inherit; color: #f2f2f4; background: #3a3a40; border: 1px solid #55555c; border-radius: 3px; padding: 2px 6px; caret-color: #fff; }
.pinput:focus { outline: none; border-color: var(--accent); }
.pinput.bad { border-color: #e05050; }
.pinput-why { color: #e05050; font-size: .85em; }
.pinput-why:empty { display: none; }
.msgline { margin-top: 8px; color: var(--focus); font-size: 12px; }

/* --- clip matrix --- */
nav.tabs .spacer { flex: 1; }
.tcontrols .gap { width: 14px; }
.matrix { display: flex; flex-direction: column; height: calc(100vh - 215px); min-height: 380px; }
.mx-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.mx-toolbar .spacer { flex: 1; }
.segs { display: inline-flex; }
.segs button.segbtns button.seg:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.segs button.segbtn:last-child { border-radius: 0 4px 4px 0; }
button.segbtn.on, button.launchbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mx-hint { color: var(--dim); font-size: 12px; margin-bottom: 6px; min-height: 1.4em; }
.mx-panes { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mx-pane { overflow: auto; min-height: 0; flex: 1 1 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.mx-bar { flex: none; height: 9px; margin: 2px 0; cursor: row-resize; background: var(--line); border-radius: 4px; touch-action: none; }
.mx-bar:hover { background: var(--accent); }
.mx-grid { display: grid; grid-template-columns: 150px repeat(var(--cols), minmax(110px, 1fr)); gap: 4px; padding: 6px; align-items: stretch; }
.mx-corner { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; align-self: center; }
.mx-head { font-weight: 600; padding: 4px 8px; background: var(--panel2); border-radius: 4px; cursor: pointer; }
.mx-head.cur { outline: 1px solid var(--focus); }
.mx-label { display: flex; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; padding: 0 6px; min-height: 30px; }
.mx-label.sec { color: var(--text); font-weight: 600; background: var(--panel2); border-radius: 4px; cursor: pointer; flex-wrap: wrap; }
.mx-cell { display: flex; gap: 6px; align-items: center; min-height: 30px; padding: 3px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; position: relative; flex-wrap: wrap; user-select: none; }
.mx-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.mx-cell.new { color: var(--dim); justify-content: center; border-style: dashed; }
.mx-cell.stop .cname { color: var(--dim); }
.mx-cell .state { width: 1.1em; color: var(--on); }
.mx-cell .cname { font-weight: 600; }
.mx-cell .used { margin-left: auto; font-size: 10px; color: var(--dim); }
.mx-cell.playing, .mx-label.sec.playing { background: color-mix(in srgb, var(--on) 22%, var(--bg)); border-color: var(--on); }
.mx-cell.armed, .mx-label.sec.armed { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus) inset; }
.mx-cell.queued .state { animation: blink 0.8s steps(2) infinite; color: var(--focus); }
.mx-cell.cursor, .mx-label.sec.cursor { outline: 2px solid var(--focus); outline-offset: 1px; }
.mx-cell.sect.playing, .mx-cell.sect.armed { background: color-mix(in srgb, var(--bg) 80%, var(--panel2)); }
.tools { display: inline-flex; gap: 3px; margin-left: auto; }
.tools button.part { padding: 0 6px; line-height: 1.2; }

/* --- widgets (the numbers are in src/web/widgets/theme.ts) --- */
.w-cell { box-sizing: border-box; flex: none; padding: var(--w-outer); user-select: none; touch-action: none; }
.w-frame { box-sizing: border-box; width: 100%; height: 100%; padding: var(--w-inner); border: var(--w-frame-width) var(--w-frame-style) transparent; border-radius: var(--w-frame-radius); background: var(--w-frame-bg-idle); }
.w-cell.sel > .w-frame { border-color: var(--w-frame-colour); background: var(--w-frame-bg); }
.w-area { width: 100%; height: 100%; overflow: visible; }
.w-svg { display: block; overflow: visible; }
.w-num { font-variant-numeric: tabular-nums; }
/* the number of a knob: a click on it types the value (SPEC 2.212), the cursor says so; its whole box takes the mouse, not only the letters */
.w-cell.knob .w-num { pointer-events: bounding-box; cursor: text; }
/* only the dial of a knob takes a drag (the value and the label around it pan the Track) */
.knob { cursor: default; }
.knob .knob-dial { cursor: ns-resize; }
.w-cell.off { opacity: var(--k-dimmed, .35); }
.w-row { display: flex; flex-wrap: wrap; gap: var(--w-gap); }
.gallery { padding: 16px; display: grid; gap: 18px; }
.gallery h3 { margin: 0 0 6px; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.gallery .scale { display: flex; gap: 8px; align-items: center; color: var(--dim); font-size: 12px; }

.ename.seqname { box-sizing: border-box; padding: 0 4px; font-size: 12px; color: var(--text); }
.ename.fixed { color: var(--dim); }

/* the + frame at the end of the strip: a slim module with a plus */
button.addmod { flex: none; align-self: stretch; width: calc(var(--u) * 7); min-height: calc(var(--u) * 20); display: grid; place-items: center; background: transparent; border: 1px dashed var(--line); border-radius: 6px; color: var(--dim); font-size: calc(var(--u) * 3); padding: 0; }
button.addmod:hover { border-color: var(--accent); color: var(--accent); }
.strip-head button { margin: 0 4px; }
input.ccnum { width: calc(var(--u) * 6); }
input.ccname { width: calc(var(--u) * 11); }
.w-cell.ccdot { cursor: default; }
.livestat { margin: 2px 0 6px; min-height: 1.4em; }
.clockstat { font-variant-numeric: tabular-nums; opacity: 0.8; margin: 0 6px; white-space: nowrap; }
.controlpanel { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.ccsfield { display: inline-flex; align-items: center; gap: 4px; }
input.ccslist { width: 12em; }

/* the rack: one page, a fixed header, the strips scroll */
html, body { height: 100%; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100vh; }
.rackhead { position: static; flex: none; }
.rackhead .hgroup { display: inline-flex; align-items: center; gap: 6px; }
.rackhead button.panic { background: var(--danger); border-color: var(--danger); color: #fff; }
input.projname { width: 11em; }
.status { position: static; flex: none; }
main.rack { flex: 1; min-height: 0; overflow-y: auto; padding: 0; display: flex; flex-direction: column; gap: 0; }
.rackmenu { position: fixed; z-index: 30; min-width: 230px; display: flex; flex-direction: column; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.rackmenu .psep { flex: none; height: 1px; background: color-mix(in srgb, var(--dim) 35%, var(--line)); margin: 4px 0; }
.clockstat, .controlstat { white-space: nowrap; }

/* touch: the rack scrolls up and down by itself, pinching zooms the strips (gesture.ts), nothing selects text or opens the browser's menus */
main.rack { touch-action: pan-y; -webkit-touch-callout: none; user-select: none; overscroll-behavior: contain; }
main.rack input { user-select: text; }
.chain { touch-action: none; }
.status[hidden] { display: none; }
.status { justify-content: center; }
@media (pointer: coarse) {
  button, select, input { min-height: 36px; }
  .rackmenu .pitem, .popup .pitem { padding: 12px 14px; }
}
@media (max-width: 700px) {
  .rackhead { gap: 6px; padding: 6px 8px; }
}

/* the strips: no padding, one line between them (the one under the header); the first column is the name of the Track on its colour */
.striprow { flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.namecol { flex: none; box-sizing: border-box; width: calc(var(--u) * 14); padding: calc(var(--u) * .5) calc(var(--u) * 1) calc(var(--u) * 1); background: hsl(var(--sh) 42% 26%); color: #fff; overflow: hidden; }
.namecol .stripname { font-size: calc(var(--u) * 1.9); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; cursor: text; }
.namecol input.stripname { box-sizing: border-box; width: 100%; padding: 2px 4px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .45); color: #fff; font: inherit; font-size: calc(var(--u) * 1.9); font-weight: 600; user-select: text; }
.namecol { position: relative; }
/* the triangle of a Track: as large as the one of a module, in the upper right corner of the name column whether the Track is open or folded */
.namecol .trackfold { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: calc(var(--u) * 3); height: calc(var(--u) * 3); min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: #fff; opacity: .85; font-size: calc(var(--u) * 2.6); line-height: 1; cursor: pointer; }
.namecol .trackfold:hover { opacity: 1; background: rgba(255, 255, 255, .15); }
.namecol .stripname { padding-right: calc(var(--u) * 2.4); }
/* folded: one line in the colour of the Track, the name column keeps its width so the triangle stays where it is; the strip stays alive behind it */
.striprow.collapsed { background: hsl(var(--sh) 42% 26%); }
.striprow.collapsed .stripwrap { display: none; }
.striprow.collapsed .namecol { min-height: calc(var(--u) * 3); padding-top: calc(var(--u) * .5); padding-bottom: calc(var(--u) * .5); }
.striprow.collapsed .namecol .stripname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* moving a Track: it follows the pointer, the others make room */
.striprow { position: relative; transition: transform .15s ease; }
.striprow.dragging { z-index: 20; transition: none; opacity: .9; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.stripwrap { flex: 1; min-width: 0; padding: 0 calc(var(--u) * .75); background: hsl(var(--sh) 45% 9%); }
.addrow { flex: none; display: flex; }
button.addstrip { flex: none; width: calc(var(--u) * 14); min-height: 44px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--dim); font-size: 22px; text-align: center; padding: 0; }
button.addstrip:hover { color: var(--accent); }
.rackmenu .swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 6px 8px; }
.rackmenu button.swatch { min-height: 28px; padding: 0; background: hsl(var(--sh) 45% 38%); border: 2px solid transparent; border-radius: 6px; }
.rackmenu button.swatch.on { border-color: #fff; }

/* only the chain of a strip scrolls sideways: never the rack, so the name columns stay where they are */
main.rack { overflow-x: hidden; }

/* the strip: no padding, as high as a module (36 u); modules are square and transparent so the colour of the Track shines through */
.stripwrap { padding: 0; }
.chain { gap: 0; padding: 0; height: calc(var(--u) * 36); align-items: stretch; }
.mod { box-sizing: border-box; height: calc(var(--u) * 36); background: transparent; border: 0; border-right: 1px solid var(--line); border-top: calc(var(--u) * .5) solid var(--c); border-radius: 0; }
.mhead { box-sizing: border-box; height: calc(var(--u) * 3.5); padding: 0 calc(var(--u) * 1); align-items: center; background: color-mix(in srgb, var(--c) 22%, transparent); }
.mtitle { font-size: calc(var(--u) * 1.9); }
.mrole { font-size: calc(var(--u) * 1.2); }
.mbody { padding: calc(var(--u) * 1); }
.outs { top: 0; }
button.addmod { align-self: stretch; min-height: 0; border: 0; border-left: 1px dashed var(--line); border-radius: 0; }
/* in connect mode the published names float under the strip, so the row keeps the height of a module */
.buses { position: absolute; left: 0; top: 100%; z-index: 15; margin: 0; padding: 4px 8px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 16px rgba(0, 0, 0, .4); }

.status .msg { color: var(--text); }

/* the grid: module bodies are built from cells of whole grid units (4 x 5 u), no padding of their own. The slots are a column (or more) at the left; right of them is the parameter area:
   the fields (device, channel) are its first rows, across its whole width, and the knobs fill what is left of the 30 u */
.mbody { flex-direction: column; gap: 0; padding: calc(var(--u) * 1) 0; }
.mbody > .cols { display: flex; flex: none; gap: 0; }
.ins { height: var(--w-body); }
.mid { gap: 0; flex: none; }
.mid > .band { display: flex; flex-direction: column; flex: none; }
.band-row { display: flex; flex-direction: row; }
/* two fields in a row (channel, voices) share the width of the module equally, the right end in line with the device field above */
.band-row > .w-cell.field:only-child { width: 50% !important; }
.band-row > .w-cell.field:not(:only-child) { width: auto !important; flex: 1 1 0; min-width: 0; }
.mid:has(> .band) { min-width: calc(var(--u) * 20); }
/* the Clock: its device field is as wide as its two knob cells (SPEC 2.133), not the width a field asks for elsewhere */
.mod[data-type="clock"] .mid:has(> .band) { min-width: 0; }
.knobs { height: calc(var(--w-body) - var(--band, 0px)); padding: 0; }
.outs { top: 0; height: 100%; padding: calc(var(--u) * 1) 0; }
.outcols { height: var(--w-body); }
/* in connect mode a collapsed module on the left of the connecting one is widened by its output ports, beside its vertical header (no grid: SPEC 2.125) */
.mod.collapsed:has(> .outs:not([hidden])) { width: auto; flex-direction: row; }
.mod.collapsed:has(> .outs:not([hidden])) > .mhead { flex: none; width: calc(var(--u) * 4); }
.mod.collapsed > .outs { position: static; box-shadow: none; background: transparent; padding: calc(var(--u) * 1) calc(var(--u) * .5) calc(var(--u) * 1) 0; }
/* the field: a label and a black box that looks like an entry field */
.w-cell.field { cursor: text; }
.w-cell.field.off { opacity: var(--k-dimmed, .4); }
.w-area.f-area { display: flex; justify-content: center; min-width: 0; }
.w-area.f-above { flex-direction: column; }
.w-area.f-left { flex-direction: row; align-items: center; }
.f-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.f-box { box-sizing: border-box; display: flex; align-items: center; flex: none; width: 100%; min-width: 0; }
.f-left .f-box { flex: 1; width: auto; }
.f-box:focus-within { border-color: var(--f-focus) !important; }
input.f-input { flex: 1; min-width: 0; width: 0; padding: 0; background: transparent; border: 0; outline: 0; text-overflow: ellipsis; }
input.f-input[readonly] { cursor: pointer; }
.f-arrow { flex: none; align-self: stretch; display: grid; place-items: center; cursor: pointer; }

/* collapsing: a triangle at the right end of the header; collapsed, the module is a column of 4 u (one grid unit) with the tinted header over its whole height, the bright bar on top, and the name turned 90 degrees counterclockwise */
button.mcollapse { flex: none; display: grid; place-items: center; width: calc(var(--u) * 3); height: calc(var(--u) * 3); padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text); opacity: var(--mc-opacity, .85); font-size: calc(var(--u) * 2.6); line-height: 1; cursor: pointer; }
button.mcollapse:hover { opacity: var(--mc-hover, 1); background: color-mix(in srgb, var(--c) 30%, transparent); }
.mod.collapsed { width: calc(var(--u) * 4); min-width: 0; }
.mod.collapsed > .mhead { flex: 1; height: auto; flex-direction: column; justify-content: flex-start; align-items: center; gap: calc(var(--u) * 1); padding: calc(var(--u) * .5) 0; }
.mod.collapsed .mtitle { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.mod.collapsed .mrole { display: none; }

/* the collapse triangle keeps the same distance to the right border of the module, expanded and collapsed (the collapsed column is 4 u wide with the 3 u button centred: 0.5 u) */
.mod:not(.collapsed) > .mhead { padding-right: calc(var(--u) * .5); }

/* the entry popup: a field at the slot or knob it belongs to */
.popup.entry { min-width: 15em; padding: 8px; }
input.popinput { box-sizing: border-box; width: 100%; padding: 6px 8px; background: #000; border: 1px solid var(--accent); border-radius: 4px; color: var(--text); font: inherit; outline: 0; }
.pophint { margin-top: 6px; color: var(--dim); font-size: 12px; }
.pophint.bad { color: var(--danger); }

.popup.entry { width: 16em; max-width: 90vw; }
.pophint { white-space: normal; }

/* the title and the triangle give the header its width; the role takes what is left (it counts for nothing in the width of the module, and fit() hides it when it does not fit) */
.mtitle { flex: none; }
.mrolebox { flex: 1 1 0; min-width: 0; contain: inline-size; overflow: hidden; display: flex; justify-content: flex-end; margin-left: calc(var(--u) * 1); }
.mrole { white-space: nowrap; visibility: hidden; }
.mod.collapsed .mrolebox { display: none; }

/* the header spacing is in u as well, so a slim module can be slim */
.mod:not(.collapsed) > .mhead { gap: calc(var(--u) * .5); padding-left: calc(var(--u) * 1); }
.mrolebox { margin-left: 0; }

/* a module that is wider than its widgets (a title decides its width, as with Knobs) centres them horizontally */
.mbody { align-items: center; }

/* the activity lights in the headers of MIDI in (a message came in: green) and MIDI out (a message went out: orange, or could not be sent: red); collapsed, at the bottom of the narrow column */
.led { flex: none; width: calc(var(--u) * 1.2); height: calc(var(--u) * 1.2); border-radius: 50%; background: rgba(255, 255, 255, .2); transition: background .08s; }
.led.in.on { background: #5fd35f; }
.led.out.on { background: #ffab33; }
.led.out.bad { background: #ff4d4d; }
.mod.collapsed .led { margin-top: auto; margin-bottom: calc(var(--u) * .8); }

button.learnbtn { margin-top: 6px; width: 100%; }
button.learnbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* the parameter area of a module with a layout is a grid of 4 x 5 u units; each widget sits in its place */
.knobs.grid { display: grid; flex-direction: initial; flex-wrap: initial; padding: 0; }
.w-cell.button { cursor: pointer; align-self: center; }
/* a button on the height of the circle of a knob (SPEC 2.135): one line for its name, so that the place of its box can be worked out */
.w-cell.button.onarc .b-name { line-height: 1; }
.w-area.b-area { display: flex; flex-direction: column; align-items: stretch; justify-content: center; }
.b-name { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-box { box-sizing: border-box; width: 100%; display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * .5); background: var(--b-fill); transition: background .1s; overflow: hidden; }
.w-cell.button.lit .b-box { background: var(--b-lit); border-color: var(--b-lit-stroke) !important; }
/* a button that does not apply now (a choice that needs an input that is not connected) */
.w-cell.button.off { opacity: .4; }
.w-cell.button.off .b-box { cursor: default; }
.w-cell.button.off.dimmed .b-box { cursor: pointer; }
.w-cell.button.pressed .b-box { filter: brightness(1.5); }
.w-cell.button.active .b-box { outline: 2px solid var(--focus); }
.b-dot { flex: none; border-radius: 50%; }
.b-label { white-space: nowrap; }
.w-area .d-box { box-sizing: border-box; width: 100%; height: 100%; position: relative; }
.d-in { position: absolute; overflow: hidden; }
.d-bar { position: absolute; left: 0; right: 0; bottom: 0; transition: height .03s linear; }
.d-lines { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
.horizontal .d-lines { top: 0; bottom: 0; }
.d-line { position: absolute; left: 0; right: 0; }
/* the horizontal display: the bar grows from the left, the lines stand upright */
.w-cell.horizontal .d-bar { top: 0; right: auto; bottom: 0; height: auto; transition: width .03s linear; }
.w-cell.horizontal .d-line { top: 0; bottom: 0; left: auto; right: auto; }

/* the Scale module: a vertical keyboard like a real one seen from the side. A white key is a long bar; where a black key lies across it,
   the white body continues behind the black key (to the right of it), as on a real keyboard. Black keys are short and dark. */
.knobs.grid .w-cell.key { align-self: stretch; padding: 0; position: relative; cursor: pointer; --wk: #dcdcdc; --bk: #141414; --kb: calc(var(--u) * .22); }
.w-cell.key.white.on { --wk: color-mix(in srgb, var(--c) 70%, #fff); }
.w-cell.key.black.on { --bk: var(--c); }
.w-cell.key.white { z-index: 1; }
/* a black key is in front, and only its own face takes the pointer: the white body to the right of it belongs to the white keys behind */
.w-cell.key.black { z-index: 2; pointer-events: none; }
.w-cell.key.black .k-face { pointer-events: auto; }
.mod.fill .mbody { padding: 0; }
.w-cell.key .k-face { position: absolute; left: 0; top: 0; bottom: 0; box-sizing: border-box; border: var(--kb) solid #0b0605; border-radius: 0 calc(var(--u) * .7) calc(var(--u) * .7) 0; }
/* a white key has a line on its top edge only: where two white keys meet there is one line, as thick as the line between a black and a white key */
.w-cell.key.white .k-face { width: 100%; background: var(--wk); border-bottom: 0; }
/* a black key is a little taller than its row (1 px above and below), and its rounded right corners show the white key behind it */
.w-cell.key.black .k-face { width: 58%; top: -1px; bottom: -1px; background: var(--bk); border-color: #0b0605; }
.w-cell.key.ext-up .k-face { border-top: 0; border-top-right-radius: 0; }
.w-cell.key.ext-down .k-face { border-bottom: 0; border-bottom-right-radius: 0; }
.w-cell.key .k-ext { position: absolute; left: 50%; right: 0; height: 50%; box-sizing: border-box; background: var(--wk); border: var(--kb) solid #0b0605; border-left: 0; pointer-events: auto; }
.w-cell.key .k-ext.up { top: -50%; border-bottom: 0; border-top-right-radius: calc(var(--u) * .7); }
.w-cell.key .k-ext.down { bottom: -50%; border-top: 0; border-bottom: 0; border-bottom-right-radius: calc(var(--u) * .7); }
.w-cell.key.white:hover { filter: brightness(1.1); }
.knobs.grid .w-cell.vfield { align-self: stretch; padding: 1px calc(var(--u) * 1); }
.w-cell.vfield .vf-box { position: relative; display: flex; width: 100%; height: 100%; }
.w-cell.vfield .vf-input { width: 100%; height: 100%; box-sizing: border-box; padding: 0; text-align: center; font-size: calc(var(--u) * 1.4); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 3px; color: var(--text); cursor: ns-resize; user-select: none; }
.w-cell.vfield.labelled { display: flex; flex-direction: column; justify-content: flex-end; }
.w-cell.vfield .vf-name { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: calc(var(--u) * 1); color: var(--dim); padding-bottom: calc(var(--u) * .1); }
.w-cell.vfield.labelled .vf-input { height: calc(var(--u) * 2.6); }
/* a field that is a knob (SPEC 2.85): the scale of its input, a thin bar under the number in the colour of its source (set by the widget), from the middle; a field that does not apply is dimmed */
.w-cell.vfield .vf-scale { position: absolute; bottom: 2px; height: 2px; border-radius: 1px; background: var(--dim); pointer-events: none; }
.w-cell.vfield.labelled .vf-box { height: calc(var(--u) * 2.6); }
.w-cell.vfield.off .vf-input { opacity: var(--k-dimmed, .45); }
.w-cell.vfield.drawn .vf-input { font-style: italic; }
.w-cell.vfield .vf-input:not([readonly]) { cursor: text; user-select: text; border-color: var(--focus); }

/* the MIDI monitor: under the strips, above the status line */
.monitor { flex: none; display: flex; flex-direction: column; height: min(240px, 38vh); background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; }
.monitor[hidden] { display: none; }
.monitor .monhead { user-select: none; display: flex; align-items: center; gap: 12px; padding: 4px 12px; border-bottom: 1px solid var(--line); }
.monitor .monhead button { padding: 2px 10px; min-height: 0; }
.monitor .monhead label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.monitor .mcount { color: var(--dim); }
.monitor .mhint { color: var(--dim); margin-left: auto; }
.monitor .mlist { flex: 1; overflow: auto; font-family: ui-monospace, Consolas, monospace; padding: 2px 0; user-select: text; }
.monitor .mrow { display: grid; grid-template-columns: 70px 90px 20px 230px minmax(160px, 1fr) minmax(0, 2fr); gap: 8px; padding: 1px 12px; white-space: nowrap; }
.monitor .mrow.dir-out { color: color-mix(in srgb, var(--text) 70%, #6cf); }
.monitor .mrow.kind-clock, .monitor .mrow.kind-transport { color: var(--dim); }
.monitor .mrow.kind-chord { color: #8f8; background: rgba(120, 255, 120, .08); }
.monitor .mrow .md { text-align: right; color: var(--dim); }
.monitor .mrow .minfo { color: #fc6; overflow: hidden; text-overflow: ellipsis; }
.monitor .mrow.late .minfo { color: #f66; font-weight: 600; }
.monitor .mrow .mport { overflow: hidden; text-overflow: ellipsis; }
.monitor { position: relative; }
.monitor .monsplit { position: absolute; left: 0; right: 0; top: -4px; height: 9px; cursor: row-resize; touch-action: none; z-index: 3; }
.monitor .monsplit::after { content: ""; position: absolute; left: 50%; top: 3px; width: 48px; height: 3px; margin-left: -24px; border-radius: 2px; background: var(--line); }
.monitor .monsplit:hover::after { background: var(--dim); }
/* the Tracks are scrolled by panning (and the wheel), no scrollbar */
main.rack { scrollbar-width: none; }
main.rack::-webkit-scrollbar { display: none; }
/* a header button that is on (the monitor is open) */
.rackhead button.toggled { background: color-mix(in srgb, var(--focus) 38%, var(--panel2)); border-color: var(--focus); color: #fff; }

/* the line curve of the Quantizer (colours and widths are in theme.ts): the drawing area is inset from the clipping edge of the box; one fine line across the whole height in the middle */
.w-cell.plot .d-box { position: relative; }
.w-cell.plot .plot-svg { position: absolute; display: block; overflow: visible; }
.w-cell.plot .plot-line, .w-cell.plot .plot-old { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.w-cell.plot .plot-dividers { position: absolute; inset: 0; pointer-events: none; }
.w-cell.plot .plot-divider, .w-cell.plot .plot-cursor { position: absolute; top: 0; bottom: 0; transform: translateX(-50%); pointer-events: none; }
.w-cell.plot .plot-centre { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); pointer-events: none; }

/* the colour of a module: a row of swatches in its menu (the colours of the Tracks, shown as the module wears them) */
.popup .pswatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 6px 8px; }
.popup button.pswatch { min-height: 24px; padding: 0; background: hsl(var(--sw) 65% 55%); border: 2px solid transparent; border-radius: 6px; }
.popup button.pswatch.on { border-color: #fff; }
.popup button.pswatch:hover { filter: brightness(1.15); }
/* the held notes on the Quantizer's curve: a green dot on the middle line, a red dot at the distance where a note was moved to */
.w-cell.plot .plot-marks { position: absolute; pointer-events: none; }
.w-cell.plot .plot-dot { position: absolute; left: 50%; border-radius: 50%; transform: translate(-50%, -50%); box-sizing: border-box; }

/* the modules that are selected (copy, cut, paste) */
.mod.selected { outline: 2px solid var(--focus); outline-offset: -2px; }
.mod.selected > .mhead { background-image: linear-gradient(rgba(255, 255, 255, .08), rgba(255, 255, 255, .08)); }

/* the pages of the Drums module: tabs above, then a grid of 4 x 4 cells with the pitches or 16 sliders */
.w-cell.drums .dr-page, .w-cell.turing .dr-page { display: flex; flex-direction: column; width: 100%; height: 100%; gap: calc(var(--u) * .5); }
.dr-tabs { display: flex; gap: calc(var(--u) * .4); flex: none; }
.dr-tab { flex: 1; min-height: 0; height: calc(var(--u) * 2.4); padding: 0; font-size: calc(var(--u) * 1.2); color: var(--dim); background: var(--panel2); border: 1px solid var(--line); border-radius: calc(var(--u) * .5); }
.dr-tab.on { color: #fff; border-color: var(--c); background: color-mix(in srgb, var(--c) 35%, var(--panel2)); }
.dr-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: calc(var(--u) * .3); }
.dr-sliders { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(16, 1fr); gap: calc(var(--u) * .3); touch-action: none; cursor: ns-resize; }
.dr-col { position: relative; background: rgba(0, 0, 0, .45); border: 1px solid var(--chan, var(--line)); border-radius: calc(var(--u) * .6); overflow: hidden; }
.dr-fill { position: absolute; left: 0; right: 0; background: var(--c); opacity: .85; pointer-events: none; }
.dr-val { position: absolute; top: calc(var(--u) * .5); left: 0; right: 0; text-align: center; font-size: calc(var(--u) * .9); color: var(--text); pointer-events: none; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.dr-zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--dim); opacity: .7; pointer-events: none; }
.dr-names { flex: none; display: grid; grid-template-columns: repeat(16, 1fr); gap: calc(var(--u) * .3); }
.dr-name { text-align: center; font-size: calc(var(--u) * 1); color: var(--dim); white-space: nowrap; overflow: hidden; }
.dr-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: calc(var(--u) * .4); }
.dr-cell { display: grid; grid-template-rows: 1fr 1fr; gap: calc(var(--u) * .2); min-height: 0; padding: calc(var(--u) * .2) calc(var(--u) * .3); border: 1px solid var(--cell, var(--line)); border-radius: calc(var(--u) * .4); }
.dr-row { display: flex; align-items: center; gap: calc(var(--u) * .3); min-height: 0; min-width: 0; }
.dr-row .w-cell.vfield { flex: 1; min-width: 0; height: 100%; min-height: 0; padding: 0; }
.dr-lab { flex: none; font-size: calc(var(--u) * .9); color: var(--dim); }
.dr-arrow { flex: none; font-size: calc(var(--u) * 1.1); color: var(--dim); }
.dr-nameinput { flex: 1; min-width: 0; height: 100%; box-sizing: border-box; padding: 0 calc(var(--u) * .4); font-size: calc(var(--u) * 1.1); text-align: center; color: var(--name, var(--text)); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 3px; }
.dr-nameinput::placeholder { color: var(--dim); opacity: .7; }
.dr-dot { flex: none; box-sizing: border-box; width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); min-height: 0; padding: calc(var(--u) * .6); border: 0; border-radius: 50%; background: var(--dot); background-clip: content-box; cursor: pointer; }
.dr-dot:hover { background-color: color-mix(in srgb, var(--dot) 70%, #fff 12%); background-clip: content-box; }
.dr-cell .w-cell.vfield { width: 100%; height: 100%; min-height: 0; padding: 0; }

/* the velocity curve of the channel under the pointer: a square display at the lower left of the Drums module */
.dr-curvebox { position: absolute; left: calc(var(--u) * 2); bottom: calc(var(--u) * 2); width: calc(var(--u) * 14); height: calc(var(--u) * 14); box-sizing: border-box; padding: calc(var(--u) * .8); pointer-events: none; z-index: 6; }
.dr-curvebox[hidden] { display: none; }
.dr-curvesvg { display: block; width: 100%; height: 100%; overflow: visible; }
.dr-curvediag { fill: none; stroke: var(--line); stroke-width: 1; opacity: .6; vector-effect: non-scaling-stroke; }
.dr-curveline { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.dr-curvevalue { position: absolute; left: calc(var(--u) * 1); top: calc(var(--u) * .4); font-size: calc(var(--u) * 1); color: var(--dim); }

/* the channels of the Drums module flash after a note: green if it played, red if it was dropped (the tooltip says why) */
.dr-cell.hit-played, .dr-col.hit-played { box-shadow: 0 0 0 2px #4dff6e inset; }
.dr-cell.hit-dropped, .dr-col.hit-dropped { box-shadow: 0 0 0 2px #ff4d4d inset; }
.mhead .dr-unmapped { margin-left: auto; margin-right: calc(var(--u) * .6); padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * 1.1); color: #1b1b1b; background: #ffb84d; border-radius: calc(var(--u) * .4); white-space: nowrap; }

/* the Turing module: a row for each lane (name, lock, edit, loop), the memory slots and the edit actions at the right */
.tu-main { flex: 1; min-height: 0; display: flex; gap: calc(var(--u) * .6); }
.tu-lanes { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * .3); }
.tu-lane { flex: 1; min-height: 0; display: flex; align-items: stretch; gap: calc(var(--u) * .3); padding: calc(var(--u) * .2); border: 1px solid var(--lane, var(--line)); border-radius: calc(var(--u) * .4); }
.tu-name { flex: none; width: calc(var(--u) * 3.6); align-self: center; text-align: center; font-size: calc(var(--u) * 1.1); overflow: hidden; white-space: nowrap; }
.tu-tip { position: fixed; z-index: 1000; pointer-events: none; white-space: pre; text-align: center; padding: 2px 6px; font-size: 12px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; }
.tu-lanes { position: relative; }
.tu-hd { flex: none; width: calc(var(--u) * 3.6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * .3); touch-action: none; cursor: ns-resize; }
/* the groups of a lane (SPEC 2.106): a slim column of buttons, one for each group, at the right of the lanes */
/* a lane that is moved with Shift + drag (SPEC 2.120): it lies over the others while it follows the pointer */
.tu-lane.tu-moving { position: relative; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.5); cursor: grabbing; }
.tu-btn.tu-grp { padding: 0; width: calc(var(--u) * 1.7); font-size: calc(var(--u) * .9); }
.tu-hd .tu-name { width: 100%; align-self: auto; }
.tu-selbtn { flex: none; align-self: stretch; width: calc(var(--u) * 2.8); min-height: 0; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.tu-selbtn svg { width: calc(var(--u) * 2.1); height: calc(var(--u) * 2.1); display: block; }
.tu-scroll { position: absolute; top: 0; bottom: 0; right: 0; width: calc(var(--u) * .35); pointer-events: none; }
.tu-thumb { position: absolute; left: 0; right: 0; background: rgba(255, 255, 255, .35); border-radius: 2px; }
.tu-loop.selmode { cursor: cell; }
.tu-loop { flex: 1; min-height: 0; height: auto; }
.tu-loop { flex: 1; min-width: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .45); border-radius: calc(var(--u) * .3); touch-action: none; cursor: crosshair; }
.tu-btn { flex: none; min-height: 0; padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * 1); color: var(--dim); background: var(--panel2); border: 1px solid var(--line); border-radius: calc(var(--u) * .4); }
.tu-clrsel { display: flex; align-items: center; justify-content: center; padding: 0; }
.tu-clrsel svg { width: calc(var(--u) * 1.35); height: calc(var(--u) * 1.35); flex: none; display: block; }
.tu-btn.tu-clrsel.has { color: #ff4d4d; border-color: #ff4d4d; }
.tu-row .tu-btn.tu-gear { font-size: calc(var(--u) * 1.73); line-height: 1; padding: 0; }
.tu-btn.on, .tu-btn.down { color: #fff; border-color: var(--c); background: color-mix(in srgb, var(--c) 35%, var(--panel2)); }
.tu-side { flex: none; width: calc(var(--u) * 17); display: flex; flex-direction: column; gap: calc(var(--u) * .3); --row: calc(var(--u) * 2.3); }
.tu-group { min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * .2); padding: calc(var(--u) * .2); border: 1px solid var(--line); border-radius: calc(var(--u) * .5); background: rgba(255, 255, 255, .03); }
.tu-memgroup { flex: 1; min-height: 0; }
.tu-editgroup { flex: none; }
.tu-recgroup { flex: none; }
.tu-grouptitle { flex: none; font-size: calc(var(--u) * .7); line-height: 1; color: var(--dim); text-align: center; }
.tu-mem { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: calc(var(--u) * .2); }
.tu-group .tu-row { flex: none; height: var(--row); }
.tu-slot { min-height: 0; padding: 0; font-size: calc(var(--u) * .8); line-height: 1; color: var(--dim); background: rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: calc(var(--u) * .3); }
.tu-slot.filled { color: var(--text); background: color-mix(in srgb, var(--c) 30%, #000); }
.tu-slot.active { border-color: var(--c); color: #fff; }
.tu-slot.sel { box-shadow: 0 0 0 2px #fff inset; }
.tu-row { flex: 1; min-height: 0; display: flex; gap: calc(var(--u) * .25); }
.tu-row .tu-btn { flex: 1; min-height: 0; padding: 0 calc(var(--u) * .2); font-size: calc(var(--u) * .9); line-height: 1; }
.tu-row .tu-m { flex: none; width: calc(var(--u) * 2.4); padding: 0; }
.tu-row .tu-tri { font-size: calc(var(--u) * 1.2); }
/* record: a red dot, and a red frame while it records (grey otherwise) */
.tu-rec, .tu-row .tu-rec { display: flex; align-items: center; justify-content: center; }
.tu-rec::before { content: ""; width: calc(var(--u) * 1); height: calc(var(--u) * 1); border-radius: 50%; background: #ff4d4d; }
.tu-btn.tu-rec.on, .tu-btn.tu-rec.down { color: #ff4d4d; border-color: #ff4d4d; box-shadow: 0 0 0 1px #ff4d4d inset; background: var(--panel2); }
/* the lanes page: a cell for each lane with a coloured header (its number) and fields of a normal height, with room round them */
.tu-lanesgrid { grid-template-rows: none; grid-auto-rows: min-content; align-content: start; gap: calc(var(--u) * .6); }
.tu-lanesgrid .dr-cell { display: flex; flex-direction: column; gap: calc(var(--u) * .5); padding: 0 0 calc(var(--u) * .6); overflow: hidden; }
.tu-cellhead { flex: none; height: calc(var(--u) * 1.6); line-height: calc(var(--u) * 1.6); text-align: center; font-size: calc(var(--u) * 1.05); color: #fff; background: var(--cell); }
.tu-lanesgrid .dr-row { flex: none; height: calc(var(--u) * 1.9); padding: 0 calc(var(--u) * .8); }
.tu-lanesgrid .dr-row.tu-range { height: auto; align-items: flex-end; }
.tu-lab2 { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: calc(var(--u) * .1); }
.tu-lab2 .dr-lab { text-align: left; line-height: 1; }
.tu-lanesgrid .tu-lab2 .dr-nameinput { flex: none; width: 100%; height: calc(var(--u) * 1.9); font-size: calc(var(--u) * 1.1); }
.tu-lab2 .w-cell.vfield { width: 100%; height: calc(var(--u) * 1.9); }
.tu-lanesgrid .w-cell.vfield { padding: 0; }
.tu-lanesgrid .w-cell.vfield .vf-input { font-size: calc(var(--u) * 1.1); }
.tu-lanesgrid .dr-row { gap: calc(var(--u) * .7); }
.tu-lanesgrid .dr-dot { width: calc(var(--u) * 2); height: calc(var(--u) * 2); padding: calc(var(--u) * .45); }

/* arp: the user page: 16 steps in two rows of 8, a slider for the number of the note and a field for the octave */
.w-cell.display.arp .w-area { padding: calc(var(--u) * .4); }
.fg-frame { position: relative; }
.kb-oct { width: 100%; height: 100%; display: flex; flex-direction: column; gap: calc(var(--u) * .4); }
.kb-oct button { flex: 1; min-height: 0; padding: 0; font-size: calc(var(--u) * 1.1); color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: calc(var(--u) * .4); cursor: pointer; }
.fg-anchor { position: absolute; width: 1px; height: 1px; pointer-events: none; }
.fg-tip { display: none; position: absolute; padding: 1px calc(var(--u) * .4); font-size: calc(var(--u) * .9); color: var(--text); background: rgba(0, 0, 0, .75); border-radius: calc(var(--u) * .3); pointer-events: none; white-space: nowrap; z-index: 5; }
.fg-fields { display: grid; grid-template-rows: repeat(4, 1fr); gap: calc(var(--u) * .2); min-height: 0; }
.fg-fields .w-cell.vfield { width: 100% !important; height: 100% !important; min-height: 0; padding: 0 !important; }
.fg-fields .w-cell.vfield .vf-input { font-size: calc(var(--u) * 1); }
/* a small square toggle (the link of the loop range of a Head), between two knobs */
.sqtoggle { align-self: center; justify-self: start; width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); min-width: 0; padding: 0; font-size: calc(var(--u) * 1.3); font-weight: 600; line-height: 1; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: calc(var(--u) * .5); cursor: pointer; z-index: 3; }
.sqtoggle.seam { transform: translateX(-50%); }
.sqtoggle.lit { background: color-mix(in srgb, var(--c) 55%, #000); border-color: var(--c); }
/* head: the tape across the module */
.hd-anchor { position: absolute; width: 1px; height: 1px; pointer-events: none; }
.hd-frame { position: relative; box-sizing: border-box; width: 100%; height: 100%; padding: 2px; border: 2px solid var(--line); border-radius: calc(var(--u) * .4); background: rgba(0, 0, 0, .3); }
.ec-frame { box-sizing: border-box; width: 100%; height: 100%; padding: 2px; border: 2px solid var(--line); border-radius: calc(var(--u) * .4); background: rgba(0, 0, 0, .3); }
.hd-tape { display: block; width: 100%; height: 100%; }
/* harmony: the scale (a keyboard as the Scale module's, a bar for each weight) and the chord (8 notes: place, octave, pitch), each in a group frame as the sections of the Turing module */
.hm-page { width: 100%; height: 100%; display: flex; flex-direction: column; }
.hm-group { flex: 1; min-height: 0; }
.hm-scalename { flex: none; height: calc(var(--u) * 2.4); display: flex; align-items: center; padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * 1.05); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: calc(var(--u) * .4); cursor: pointer; }
.hm-scalename.readonly { cursor: default; opacity: .85; }
.hm-rows { flex: 1; min-height: 0; display: grid; }
.hm-scale-rows { grid-template-rows: repeat(12, 1fr); gap: 0; }
.hm-chord-rows { grid-template-rows: repeat(8, 1fr); gap: calc(var(--u) * .25); }
.hm-row { display: grid; min-height: 0; min-width: 0; gap: calc(var(--u) * .3); align-items: stretch; }
.hm-scale-rows .hm-row { grid-template-columns: 1fr 1fr; }
.hm-chord-rows .hm-row { grid-template-columns: 1fr 1fr 1fr; }
.knobs.grid .hm-scale-rows .w-cell.key { align-self: stretch; padding: 0; position: relative; cursor: pointer; --wk: #5c5c5c; --bk: #484848; --kb: calc(var(--u) * .22); }
.knobs.grid .hm-scale-rows .w-cell.key.white.on { --wk: color-mix(in srgb, var(--c) 70%, #fff); }
.knobs.grid .hm-scale-rows .w-cell.key.black.on { --bk: color-mix(in srgb, var(--c) 70%, #fff); }
/* the tonic row is marked by its key: a darker module colour. With the child 0 it is the root; with another child the dark key moves with it (the root has the colour of the other notes) */
.knobs.grid .hm-scale-rows .hm-row.tonic .w-cell.key.white.on { --wk: color-mix(in srgb, var(--c) 65%, #000); }
.knobs.grid .hm-scale-rows .hm-row.tonic .w-cell.key.black.on { --bk: color-mix(in srgb, var(--c) 65%, #000); }
.hm-fader { align-self: center; position: relative; height: 78%; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 3px; cursor: ew-resize; touch-action: none; overflow: hidden; user-select: none; }
.hm-fader.locked { cursor: default; }
.hm-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.hm-ghost { position: absolute; bottom: 12%; height: 12%; min-height: 2px; pointer-events: none; }
.hm-mid { position: absolute; left: calc(64 / 127 * 100%); top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255, 255, 255, .35); pointer-events: none; }
.hm-dna { position: absolute; left: 0; right: 0; top: 38%; transform: translateY(-50%); text-align: center; font-size: calc(var(--u) * .8); letter-spacing: .08em; pointer-events: none; }
.hm-row.off .hm-fader, .hm-row.off .w-cell.vfield { opacity: .4; }
.hm-scale-rows .w-cell.key.keylocked { cursor: default; }
.hm-row .w-cell.vfield { width: 100% !important; height: 100% !important; min-height: 0; padding: 0 !important; }
.hm-row .w-cell.vfield .vf-input { font-size: calc(var(--u) * 1.05); }

/* the probe windows: what an input gets (hover over a connected input, or "watch values" in its menu) */
.probe { position: fixed; z-index: 1000; pointer-events: none; padding: 3px 6px; font-size: 12px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; }
.probe.pinned { pointer-events: auto; }
.probe-head { display: flex; align-items: center; gap: 8px; }
.probe.pinned .probe-head { cursor: move; }
.probe-title { flex: 1; white-space: nowrap; }
.probe-x { flex: none; border: 0; background: none; color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.probe-body { margin: 3px 0 0; font: 12px/1.35 ui-monospace, Consolas, monospace; white-space: pre; }
.probe.pinned .probe-body { cursor: pointer; }
.probe.frozen { border-style: dashed; }
.probe { border-color: var(--probe, var(--line)); }
.probe.pinned { border-width: 2px; }
.probe-lines { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 999; }
.probe-lines line { stroke-width: 2; stroke-linecap: round; }

.w-cell.field.held input { color: var(--c); }

/* the scene panel under the header and the Crossfader module */
.scene-empty { color: var(--dim, #999); }
.scene-table { border-collapse: collapse; }
.scene-table th, .scene-table td { padding: 1px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.scene-table th { font-weight: 600; }
.scene-name { max-width: 28em; overflow: hidden; text-overflow: ellipsis; }
.scene-val { width: 5em; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; }
.cf-fader { cursor: ew-resize; }

/* the A/B switch: the side it is on */

/* the keys of the Scale: a key that is latched is a little stronger than one that is held, and the name of the lowest key is a handle for the octave */
.w-cell.key.white.on.latched { --wk: color-mix(in srgb, var(--c) 85%, #fff); }
.w-cell.key.black.on.latched { --bk: color-mix(in srgb, var(--c) 85%, #000); }
.w-cell.key .k-label { position: absolute; left: calc(var(--u) * .5); top: 50%; transform: translateY(-50%); font-size: calc(var(--u) * .95); line-height: 1; color: #222; cursor: ns-resize; z-index: 4; padding: 0 calc(var(--u) * .2); touch-action: none; }

/* a number field with its name on the left (the Math module): thin, as high as its row; the ones to type in have a black box, the results (that can only be read) none */
.knobs.grid .w-cell.vfield.labelled.left { flex-direction: row; align-items: stretch; justify-content: flex-start; gap: calc(var(--u) * .3); padding: calc(var(--u) * .15) calc(var(--u) * .4); }
.w-cell.vfield.labelled.left .vf-name { flex: none; width: calc(var(--u) * 1.8); display: flex; align-items: center; text-align: left; padding: 0; font-size: calc(var(--u) * 1.15); }
.w-cell.vfield.labelled.left .vf-input { flex: 1; min-width: 0; height: 100%; padding: 0 calc(var(--u) * .3); font-size: calc(var(--u) * 1.15); text-align: right; background: #000; }
.w-cell.vfield.labelled.left.result .vf-input { background: transparent; border-color: transparent; cursor: default; }
.w-cell.vfield.labelled.left.result.held .vf-input { color: var(--c); }

/* the Math module: ten rows of fixed heights (the entry fields and the buttons as high as the buttons of the other modules, 2 units, the result lines as high as the digits, 0.9 units: the line box of the text is taller, and the rows are made as high as what is seen), and the space that is left is shared out evenly: between the rows and
   above the first and below the last one, so that the visible space between all the lines is the same. The buttons are as wide as the rows (from the names to the right edge of the fields). */
.mod[data-type="math"] .knobs.grid { box-sizing: border-box; padding: 0; row-gap: 0; align-content: space-evenly; grid-template-rows: repeat(3, calc(var(--u) * 2)) calc(var(--u) * .9) repeat(2, calc(var(--u) * 2)) calc(var(--u) * .9) repeat(2, calc(var(--u) * 2)) calc(var(--u) * .9) !important; }
.mod[data-type="math"] .knobs.grid > .w-cell { align-self: stretch; min-height: 0; }
.mod[data-type="math"] .knobs.grid .w-cell.vfield.labelled.left { padding: 0 calc(var(--u) * .4); }
.mod[data-type="math"] .w-cell.vfield.labelled.left .vf-input { font-size: calc(var(--u) * 1.2); line-height: 1; }
.mod[data-type="math"] .knobs.grid .w-cell.vfield.labelled.left.result { align-items: center; }
.mod[data-type="math"] .w-cell.vfield.labelled.left.result .vf-input { font-size: calc(var(--u) * 1.2); line-height: calc(var(--u) * 1.2); height: calc(var(--u) * 1.2); flex: 1; border-width: 0; }
.mod[data-type="math"] .knobs.grid > .w-cell.button { width: 100% !important; height: 100% !important; padding: 0 calc(var(--u) * .4); box-sizing: border-box; }
.mod[data-type="math"] .w-cell.button .w-frame { height: 100%; padding: 0; border-width: 0; }
.mod[data-type="math"] .w-cell.button .w-area { height: 100%; }
.mod[data-type="math"] .w-cell.button .b-box { width: 100%; height: 100% !important; box-sizing: border-box; }
.sel-grid { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(6, 1fr); gap: calc(var(--u) * .4); }
.sel-btn { min-width: 0; min-height: 0; padding: 0; font-size: calc(var(--u) * 1.3); color: var(--text); background: var(--b-fill); border: calc(var(--u) * .15) solid var(--b-stroke); border-radius: calc(var(--u) * .5); cursor: pointer; transition: background .1s; }
.sel-btn.on { background: var(--b-lit); border-color: var(--b-lit-stroke); }
.sel-btn:active { filter: brightness(1.5); }
.sel-plus { color: var(--muted, var(--text)); }

/* the Crossfader: the button of the scene B, the vertical fader, the button of the scene A (SPEC 2.50) */
.w-cell.crossfader .w-area { display: block; }
.cf-col { display: flex; flex-direction: column; gap: calc(var(--u) * .4); height: 100%; width: 100%; }
.cf-frame { flex: 1 1 auto; min-height: 0; width: 100%; box-sizing: border-box; display: flex; padding: calc(var(--u) * .3); border: 1px solid var(--line); border-radius: 3px; background: rgba(0, 0, 0, .25); }
.cf-frame { position: relative; }
.cf-mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; margin-top: -.5px; background: rgba(160, 160, 168, .55); pointer-events: none; }
.cf-fader { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.cf-btn { flex: 0 0 auto; height: calc(var(--u) * 4.2); width: 100%; box-sizing: border-box; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; font-size: calc(var(--u) * 1.8); font-weight: 600; color: var(--text); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; user-select: none; touch-action: none; overflow: hidden; }
/* no highlight while the pointer is over a button: a fader dragged to its end overshoots onto the buttons */
.cf-btn:hover:not(:disabled), .cf-btn:active, .cf-btn:focus, .cf-btn:focus-visible { border-color: var(--line); outline: none; }
.cf-btn.coloured:hover:not(:disabled), .cf-btn.coloured:active, .cf-btn.coloured:focus { border-color: var(--sc); }
.cf-btn.coloured { background: color-mix(in srgb, var(--sc) 35%, #000); border-color: var(--sc); }
/* a scene with no widget in it (SPEC 2.109): no background, the colour only on the border */
.cf-btn.empty, .cf-btn.coloured.empty { background: transparent; }
.cf-btn.none { opacity: .55; font-style: italic; }
.cf-btn.locked { cursor: default; color: var(--src, var(--text)); }
.cf-btn .cf-name { font-size: calc(var(--u) * .95); font-weight: 400; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.pitem.coloured, .popup .pitem.coloured { border-left: 4px solid var(--pc); }

/* the Scenes module: the buttons of the scenes on top, the widgets of the selected scene (or the table) under them (SPEC 2.56) */
.w-cell.scenes-ed .w-area { display: block; }
.sc-col { position: relative; display: flex; flex-direction: row; height: 100%; width: 100%; min-width: 0; }
/* from the header to the bottom edge of the module: over the padding of the display (.75 u) and over the padding of the body of the module (1 u) */
.sc-sep { position: absolute; top: calc(var(--u) * -1.75); bottom: calc(var(--u) * -1.75); width: 1px; background: var(--line); pointer-events: none; }
.sc-left { flex: none; display: flex; flex-direction: column; gap: calc(var(--u) * .4); height: 100%; min-height: 0; }
.sc-radio { flex: none; display: flex; gap: calc(var(--u) * .3); }
.sc-radio .sc-tool { flex: 1 1 0; min-width: 0; }
.sc-tool { padding: 1px calc(var(--u) * .8); font-size: calc(var(--u) * 1.3); color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.sc-tool.on { background: color-mix(in srgb, var(--accent) 45%, var(--panel2)); border-color: var(--accent); }
.sc-tool:disabled { opacity: .45; cursor: default; }
.sc-apply { flex: none; width: 100%; }
/* the scene buttons: as the ones of the Cross module (class cf-btn); the one that is on has a white ring inside, as the selected slot of the memory of a Turing module */
.sc-grid { flex: 1 1 auto; min-height: 0; display: grid; grid-auto-rows: calc(var(--u) * 4.2); gap: calc(var(--u) * .4); align-content: start; overflow: hidden; }
.sc-chip { width: 100%; cursor: pointer; }
.sc-chip.on { box-shadow: inset 0 0 0 2px #fff; }
.sc-chip.add { border-style: dashed; color: var(--dim); }
/* the right part is as high as the edit grid of the modules (six rows of 5 u): it reaches over the padding of the display, so the widgets stand on the same grid as in any module */
.sc-right { flex: 1 1 0; min-width: 0; margin-left: calc(var(--sc-pad, calc(var(--u) * 1.5)) * 2 + 1px); align-self: flex-start; height: calc(var(--u) * 30); margin-top: calc(var(--u) * -.75); margin-bottom: calc(var(--u) * -.75); overflow-x: auto; overflow-y: hidden; }
/* the widgets of the selected scene on the edit grid of the modules: three rows of equal height (a base cell, the size of a knob), three to a column; each in a base cell with its source on top */
.sc-widgets { height: 100%; width: max-content; display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, calc(var(--u) * 10)); grid-auto-columns: max-content; }
.sc-cell { position: relative; box-sizing: border-box; height: calc(var(--u) * 10); min-width: calc(var(--u) * 8); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.sc-src { position: absolute; top: 0; left: 0; right: 0; padding: 0 calc(var(--u) * .6); font-size: calc(var(--u) * .85); line-height: calc(var(--u) * 1); color: var(--dim); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* the Voice module: the memory slots and the two sections of rows (SPEC 2.57) */
.w-cell.voice .w-area { display: block; }
/* the slots on top, 8 by 2, the rows under them, as wide (SPEC 2.130) */
.vc-page { width: 100%; height: 100%; display: flex; flex-direction: column; gap: calc(var(--u) * .6); }
.vc-page > .tu-group { min-width: 0; }
.vc-page > .vc-slots { flex: 0 0 calc(var(--u) * 6); }
.vc-page > .vc-rows { flex: 1 1 0; min-height: 0; }
.vc-slots .tu-mem { flex: 1; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(2, 1fr); }
/* the rows 1..8 and 9..16 in one frame, a thin line between the columns */
.vc-page > .vc-rows { position: relative; }
.vc-rows-body { flex: 1; min-height: 0; display: flex; gap: calc(var(--u) * .5); }
.vc-col { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: calc(var(--u) * .2); }
.vc-col > .hm-rows { flex: 1; min-height: 0; }
/* the line between the two columns runs from the top to the bottom of the frame (inside its border: no gap) */
.vc-sep { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; margin-left: -.5px; background: var(--line); pointer-events: none; }

/* a knob or a choice that is in a scene: a thin frame inside its cell, grey; the colour of the Crossfader that last set its value (--sf) while it still has that value */
.w-cell.in-scene { outline: 1px solid var(--sf, rgba(150, 150, 160, .4)); outline-offset: calc(var(--u) * -.3); border-radius: calc(var(--u) * .9); }
/* a number field, a button or a choice fills its cell (in some modules the cell is as high as the field): its frame stands outside the cell with some room round the field, a knob has room inside its cell. The corners of every scene frame are the same: the outline follows the radius of the element changed by its offset (knob: .9 - .3 = .6 u; here .15 + .45 = .6 u) */
.w-cell.in-scene.vfield, .w-cell.in-scene.button, .w-cell.in-scene.choice { outline-offset: calc(var(--u) * .45); border-radius: calc(var(--u) * .15); }
/* a button in a grid cell (half a knob cell high) has its frame inside its own cell, as a knob (SPEC 2.133, user): as wide as the frame of a knob, and it never reaches into the frame of the widget above or
   below it; a button that fills its cell (the operations of Math) keeps the frame outside */
.knobs.grid > .w-cell.in-scene.button { outline-offset: calc(var(--u) * -.3); border-radius: calc(var(--u) * .9); }
.mod[data-type="math"] .knobs.grid > .w-cell.in-scene.button { outline-offset: calc(var(--u) * .45); border-radius: calc(var(--u) * .15); }
/* the table in the Scenes module: small, as the rest of the module (the page uses the size of its text) */
.sc-right .scene-table { font-size: calc(var(--u) * 1.15); }
.sc-right .scene-name { max-width: calc(var(--u) * 24); }
.sc-right .scene-val { width: calc(var(--u) * 6); }

/* the table of the scenes: rows with room between the fields and the lines, and the square buttons F (fill) and X (remove from every scene) as high as the fields */
.scene-table td { padding-top: .4em; padding-bottom: .4em; }
.scene-val { height: 1.8em; box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.scene-sqcol { width: 1px; padding-left: 3px; padding-right: 3px; }
.scene-sq { width: 1.8em; height: 1.8em; padding: 0; box-sizing: border-box; font: inherit; line-height: 1; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; }
.scene-sq:hover { border-color: var(--accent); }

/* a cell of a scene that does not have the widget: nothing in it, and no fill (the background of the module shows through) */
.scene-val.empty { background: transparent; }
/* a knob in a scene: the switch of its fade or switch on this scene's half of a crossfade, then its value (SPEC 2.102) */
.scene-cell { display: flex; gap: 2px; align-items: center; }
.scene-morph.switch { color: var(--accent); }
.scene-sq.scene-morph-none { visibility: hidden; cursor: default; }

/* the Text module: the text field fills the module, with no background or frame of its own: the tint of the module shows through (SPEC 2.74) */
.w-cell.text-ed .w-frame { background: transparent; border-color: transparent; }
.w-cell.text-ed .w-area { display: block; }
.mod.fill .w-cell.text-ed { height: 100% !important; }
.tx-edit { box-sizing: border-box; display: block; width: 100%; height: 100%; margin: 0; padding: calc(var(--u) * .3); resize: none; background: transparent; color: var(--c); border: 1px solid transparent; border-radius: 3px; font-family: system-ui, sans-serif; line-height: 1.35; outline: none; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.tx-edit.fixed { font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; }
.tx-edit:hover { border-color: color-mix(in srgb, var(--line) 60%, transparent); }
.tx-edit:focus { border-color: var(--line); background: rgba(0, 0, 0, .12); }

/* a module with a name of its own: `name [title]` (SPEC 2.78). The box is as wide as the title alone (the hidden sizer), so the module is not wider than without a name; the
   two parts are laid over it and cut with …: the [title] gives way first (its shrink is huge), then the name */
.mname { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
.mname > .msizer { visibility: hidden; white-space: nowrap; }
.mname > .mnamed { position: absolute; inset: 0; }
.mtitle.mnamed { display: flex; align-items: baseline; gap: .35em; min-width: 0; min-height: 0; overflow: hidden; white-space: nowrap; }
.mnamed > .mgiven { flex: 0 1 auto; min-width: 0; min-height: 0; overflow: hidden; text-overflow: ellipsis; }
.mnamed > .mkind { flex: 0 100000 auto; min-width: 0; min-height: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 400; opacity: .75; }
/* collapsed: the name sideways is cut at the height of the module */
.mod.collapsed > .mhead { min-height: 0; overflow: hidden; }
.mod.collapsed > .mhead > .mtitle { flex: 0 1 auto; min-height: 0; overflow: hidden; text-overflow: ellipsis; }
/* Shift or Ctrl held (selecting modules): the collapse triangle lets the click through to its header and steps back */
body.selecting button.mcollapse { pointer-events: none; opacity: .25; }
/* the piano roll of the Arp (SPEC 2.89): a canvas that fills its display */
.w-cell.arp-roll .w-area { padding: 0; }
.ar-roll { display: block; width: 100%; height: 100%; }
.w-cell.arp-roll .d-box { box-sizing: border-box; }
/* a widget that does not apply now (its condition: a knob or a choice) is in its place but not seen; it comes as soon as it applies, also during a drag */
.w-cell.w-hidden { visibility: hidden; pointer-events: none; }
.pselect:disabled { opacity: .5; }
/* a knob drawn as a button (SPEC 2.129): the box where the circle of the knob would be, the name where its name is */
.w-cell.knobbtn { cursor: pointer; }
.w-area.kb-area { position: relative; }
.kb-box { position: absolute; box-sizing: border-box; background: var(--b-fill); }
.w-cell.knobbtn.lit .kb-box { background: var(--b-lit); border-color: var(--b-lit-stroke) !important; }
.w-cell.knobbtn.pressed .kb-box { filter: brightness(1.5); }
.kb-name { position: absolute; left: 0; right: 0; text-align: center; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
/* a button in the widget view of the Scenes module (SPEC 2.137): the place of a knob, the button at its top moved to the height of the middle of the circle */
.sc-btn { position: relative; display: flex; flex-direction: column; align-items: center; }
/* Progress (SPEC 2.138): the chord row; a written chord by its name, an empty step a line that goes on from the chord before it */
.w-cell.progress .w-area { display: block; }
.pg-page { width: 100%; height: 100%; display: flex; flex-direction: column; }
/* one display (SPEC 2.147), as a lane of the Turing: a grey frame (2.148: the colours are for the lanes to come) with a little room inside, the dark ground of the lane in it, the steps on it as the bars of a lane (a pixel
   apart, no lines of their own), a faint white line every four steps; every step is two grid columns, so step n stands over the knob cell n */
.w-cell.progress { padding: 0; }
.w-cell.progress > .w-frame { padding: 0; border-width: 0; background: transparent; }
.w-cell.progress .pg-page { box-sizing: border-box; margin: calc(var(--u) * .2); width: auto; height: calc(100% - var(--u) * .4); padding: calc(var(--u) * .2); border: 1px solid var(--line); border-radius: calc(var(--u) * .4); }
.pg-row { flex: 1; min-height: 0; display: grid; column-gap: 1px; background: rgba(0, 0, 0, .45); border-radius: calc(var(--u) * .3); overflow: hidden; }
.pg-step { position: relative; display: grid; grid-template-rows: 1fr auto 1fr auto; align-items: center; justify-items: center; min-width: 0; cursor: pointer; user-select: none; }
/* the four rows of a step (SPEC 2.183): the chord written, the triangle, the chord of the plan (centred between the triangle and the button), the button */
.pg-step > .pg-top { grid-row: 1; }
.pg-step > .pg-mid { grid-row: 2; }
.pg-step > .pg-plan { grid-row: 3; position: relative; top: calc(var(--u) * -.125); }  /* (the letters sat 1 px low: their box is not their caps; measured, SPEC 2.183) */
.pg-step > .pg-free, .pg-step > .pg-index { grid-row: 4; }
/* the three areas of a step (SPEC 2.156): the chord written (above), the chord the plan plays (below it), the number (at the bottom) */
.pg-top { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * .1); min-width: 0; max-width: 100%; }
.pg-step.beat::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .2); pointer-events: none; }
.pg-step.out { opacity: .25; cursor: default; }
/* (a step with a chord written has no background of its own: its field shows the chord, and the background is the playing step's alone, SPEC 2.207) */
.pg-step.cursor { box-shadow: 0 0 0 2px #fff inset; }
.pg-step.playing { background: color-mix(in srgb, var(--c) 32%, #000); } /* (was 60 %, then 45 %: too bright, user) */
.pg-name { max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; font-size: calc(var(--u) * 1.6); font-weight: 600; color: var(--text); }
.pg-num { font-size: calc(var(--u) * 1); color: var(--dim); white-space: nowrap; }
.pg-index { padding-bottom: calc(var(--u) * .15); font-size: calc(var(--u) * 1); line-height: 1; color: var(--dim); }
.pg-entry { box-sizing: border-box; width: 96%; min-width: 0; height: calc(var(--u) * 2.4); padding: 0 calc(var(--u) * .1); font: inherit; font-size: calc(var(--u) * 1.6); font-weight: 600; text-align: center; color: var(--text); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: calc(var(--u) * .3); outline: none; cursor: text; }
.pg-entry:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.pg-entry:focus { border-color: var(--c); background: #2a2a30; }
.pg-entry::placeholder { color: var(--text); opacity: .35; }
.pg-entry.bad { border-color: #e05050; }
/* the plan (SPEC 2.139): what a written chord plays instead in this round, under its name in the colour of the module */
.pg-plan { max-width: 100%; overflow: hidden; font-size: calc(var(--u) * 1.6); font-weight: 600; color: var(--c); white-space: nowrap; }
.pg-plan.held { opacity: .4; }
/* the locks (SPEC 2.140): a knob locked on the step with the cursor has a brighter ground; the steps with locks have a dot, a fixed point a ring; the steps where the knob under the mouse is locked are lit */
.w-cell.knob.steplocked { background: rgba(255, 255, 255, .09); border-radius: calc(var(--u) * .9); }
.pg-lock { position: absolute; top: calc(var(--u) * .35); right: calc(var(--u) * .35); width: calc(var(--u) * .6); height: calc(var(--u) * .6); border-radius: 50%; background: var(--c); }
.pg-lock.fixed { background: transparent; border: 2px solid #f2f2f4; width: calc(var(--u) * .5); height: calc(var(--u) * .5); }
.pg-step.lockhint { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 70%, #fff) inset; }
.pg-step.lockhint { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 70%, #fff) inset; }

/* a widget locked by hand (SPEC 2.144): the hand of the Track over it (a drag scrolls), and a small padlock in its corner */
.chain .frozen, .chain .frozen * { cursor: grab !important; }
.chain.panning .frozen, .chain.panning .frozen * { cursor: grabbing !important; }
.frozen { position: relative; }
.frozen::after { content: ""; position: absolute; top: calc(var(--u) * .3); right: calc(var(--u) * .3); width: calc(var(--u) * .9); height: calc(var(--u) * .7); border-radius: 1px; background: color-mix(in srgb, var(--dim) 70%, transparent); pointer-events: none; }
.frozen::before { content: ""; position: absolute; top: calc(var(--u) * -.05); right: calc(var(--u) * .45); width: calc(var(--u) * .6); height: calc(var(--u) * .55); border: calc(var(--u) * .14) solid color-mix(in srgb, var(--dim) 70%, transparent); border-bottom: 0; border-radius: calc(var(--u) * .35) calc(var(--u) * .35) 0 0; box-sizing: border-box; pointer-events: none; }

/* the side of Progress (SPEC 2.148, 2.150): a column of the module right of the parameter area, the memory and the edit actions as the side of the Turing: as wide (17 u), its top at the top of the
   chord row, and the room of the Turing's side to the chord row (0.6 u), the right edge (0.88 u) and the bottom edge of the module (1.75 u, measured); the memory group as high as the Turing's
   (14.81 u), the edit group takes the rest (there is no record group) and its rows share it */
.mside { flex: none; display: flex; align-items: flex-start; }
.pg-side { flex: none; box-sizing: border-box; width: calc(var(--u) * 17); height: calc(var(--u) * 29.04); margin: calc(var(--u) * .2) calc(var(--u) * .76) 0 calc(var(--u) * .4); }
.pg-side > .tu-memgroup { flex: none; height: calc(var(--u) * 14.81); }
.pg-side > .tu-editgroup { flex: 1; min-height: 0; }
.pg-side > .tu-editgroup > .tu-row { flex: 1; height: auto; }

/* the room that makes a module a whole number of units wide (SPEC 2.150): between the slots and the parameter area, so every module has the same room at its right edge */
.mbody > .cols > .mid { margin-left: var(--fit, 0px); }

/* the styles of Progress (SPEC 2.154): a list of the styles chosen, a line each, and + on the last line */
.w-cell.progress-styles .w-area { display: block; }
.pg-styles { box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: calc(var(--u) * .15); padding: calc(var(--u) * .3); background: rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: calc(var(--u) * .4); overflow: hidden; }
.pg-st-title { flex: none; font-size: calc(var(--u) * .7); line-height: 1; color: var(--dim); text-align: center; }
.pg-st { flex: none; min-height: 0; height: calc(var(--u) * 1.75); padding: 0 calc(var(--u) * .4); font-size: calc(var(--u) * 1); line-height: 1; text-align: left; color: var(--text); background: color-mix(in srgb, var(--c) 22%, transparent); border: 0; border-radius: calc(var(--u) * .25); white-space: nowrap; overflow: hidden; }
.pg-st.add { color: var(--dim); background: transparent; border: 1px dashed var(--line); text-align: center; }

/* the switch of a step (SPEC 2.161): its number, a button as the others (the mode button), 1 px from the left, bottom and right of the step; lit when the plan may change the step. A held step shows the
   chord that goes on, dimmed */
.pg-step { padding: 0 1px 1px; box-sizing: border-box; }
.pg-free { justify-self: stretch; box-sizing: border-box; min-height: 0; height: calc(var(--u) * 1.8); padding: 0; font: inherit; font-size: calc(var(--u) * 1); line-height: 1; color: var(--text); background: var(--b-fill); border: var(--b-width) solid var(--b-stroke); border-radius: var(--b-radius); cursor: pointer; transition: background .1s; }
.pg-free.on { background: var(--b-lit); border-color: var(--b-lit-stroke); }
.pg-name.held { opacity: .35; }

/* the plan's chord into the step (SPEC 2.178): a small triangle between the chord written (above) and the plan's (below), where they differ; a click writes it */
.pg-take { visibility: hidden; min-height: 0; padding: 0 calc(var(--u) * .3); font-size: calc(var(--u) * 1.6); line-height: 1; color: var(--c); background: transparent; border: 0; cursor: pointer; }
.pg-step.takeable .pg-take { visibility: visible; }
/* the middle row of a step (SPEC 2.185): the dot to hear it at the left, the triangle in the middle; the dot grows downward from where it was, until its room to the plan's letters is its room
   to the frame of the field (1.62 u, measured; SPEC 2.194: easier to hit) */
.pg-mid { position: relative; width: 100%; display: flex; justify-content: center; align-items: center; }
.pg-hear { position: absolute; left: calc(var(--u) * .5); top: 50%; transform: translateY(calc(var(--u) * -.55)); box-sizing: border-box; width: calc(var(--u) * 1.62); height: calc(var(--u) * 1.62); min-height: 0; padding: 0; border-radius: 50%; background: color-mix(in srgb, var(--c) 45%, transparent); border: 1px solid var(--c); cursor: pointer; }
.pg-hear:hover { background: color-mix(in srgb, var(--c) 70%, transparent); }
.pg-hear.on { background: #fff; border-color: #fff; }
.pg-take:hover { color: #fff; }

/* an item half a cell high at the top or bottom edge of the grid keeps the room the framed widgets keep there (SPEC 2.180): its content ends where theirs ends */
.knobs.grid > .w-cell.edge-bottom { padding-bottom: var(--w-edge); }
.knobs.grid > .w-cell.edge-top { padding-top: var(--w-edge); }
/* (the room between the edge of a cell and what a framed widget shows: its outer padding, its frame and its inner padding together, measured 0.75 u) */
.knobs.grid { --w-edge: calc(var(--u) * .75); }

/* a chord name of more than 6 characters, in the field and in the plan each by its own (SPEC 2.183): the size at which 9 (the longest, D♭maj7♯11) fit into the field */
.pg-entry.long, .pg-plan.long { font-size: calc(var(--u) * 1.2); }

/* autolock (SPEC 2.186): a button as the others when off; on, its frame and its text red */
.tu-btn.pg-autolock.on { color: #ff4d4d; border-color: #ff4d4d; background: var(--panel2); box-shadow: 0 0 0 1px #ff4d4d inset; }
