/* The studio: page frame, top rail, desk tabs, desk surfaces, device slots, jacks and cables. */

:root {
  --font: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --mono: "SF Mono", "Cascadia Mono", Consolas, Menlo, monospace;
  --logo-font: "Futura", "Century Gothic", "Avenir Next", "Trebuchet MS", sans-serif;

  --ink: #f0ede5;
  --ink-dim: #9f9c94;
  --line: rgba(240, 237, 229, 0.62);
  --focus: #7dd3ff;

  --vfd: #7dffe0;
  --vfd-dim: rgba(125, 255, 224, 0.28);
  --vfd-bg: #041210;

  --rail-ink: #d9dde2;
  --rail-dim: #858c94;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #15171a;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------- rail */

.rail {
  position: relative;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 26px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #2b2f34, #1d2024);
  border-bottom: 1px solid #050506;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  color: var(--rail-ink);
  user-select: none;
  -webkit-user-select: none;
}

.rail-brand { display: flex; align-items: baseline; gap: 8px; }
.rail-logo {
  font: 700 24px/1 var(--logo-font);
  letter-spacing: -0.01em;
  color: #e9ebee;
}
.rail-sub { font: 700 9px var(--font); letter-spacing: 0.34em; color: #e0782e; }

.rail-group { position: relative; display: flex; align-items: center; gap: 7px; }
.rail-caption { font: 700 9px var(--font); letter-spacing: 0.2em; color: var(--rail-dim); }
.rail-unit { font: 700 9px var(--font); letter-spacing: 0.12em; color: var(--rail-dim); }

.rail-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #0a0b0c;
  border-radius: 4px;
  background: linear-gradient(180deg, #41464c, #2a2d32);
  color: #ecebe6;
  font: 700 10px var(--font);
  letter-spacing: 0.12em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.rail-btn:hover { background: linear-gradient(180deg, #4b5057, #30343a); }
.rail-btn:active { transform: translateY(1px); }
.rail-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.rail-btn:focus-visible, .rail-bpm:focus-visible, .rail-select:focus-visible, .segmented button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.rail-btn.small { width: 26px; padding: 0; font-size: 14px; }

.rail-bpm {
  width: 74px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid #000;
  border-radius: 4px;
  background: radial-gradient(ellipse at 50% 40%, #0a201c, var(--vfd-bg));
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9);
  color: var(--vfd);
  font: 600 16px var(--mono);
  text-align: center;
  text-shadow: 0 0 6px var(--vfd-dim);
  appearance: textfield;
  -moz-appearance: textfield;
}
.rail-bpm::-webkit-inner-spin-button, .rail-bpm::-webkit-outer-spin-button { appearance: none; margin: 0; }

.beat-led {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #3b1208;
  box-shadow: 0 0 0 1.5px #0c0d0e, inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.beat-led.on { background: #ff8a2a; box-shadow: 0 0 0 1.5px #0c0d0e, 0 0 10px 3px rgba(255, 138, 42, 0.6); }
.beat-led.on.downbeat { background: #ff3b1f; box-shadow: 0 0 0 1.5px #0c0d0e, 0 0 14px 5px rgba(255, 59, 31, 0.7); }

.play { display: inline-flex; align-items: center; gap: 8px; }
/* PLAY and STOP keep the same width (the rest of the rail must not shift):
   a 10 px icon box either way, and both words stacked in one cell, the
   other one hidden. */
.play-icon {
  flex: none;
  width: 10px;
  height: 12px;
  background: #7ee28c;
  clip-path: polygon(0 0, 90% 50%, 0 100%);
}
.play .label { display: inline-grid; }
.play .label > span { grid-area: 1 / 1; text-align: center; }
.play .label-stop, .play.on .label-play { visibility: hidden; }
.play.on .label-stop { visibility: visible; }
.play.on { background: linear-gradient(180deg, #2f5a37, #1f3b25); }
.play.on .play-icon { height: 10px; background: #f0f0ea; clip-path: none; }

.rail-position {
  min-width: 40px;
  font: 600 13px var(--mono);
  color: var(--vfd);
  text-shadow: 0 0 6px var(--vfd-dim);
}

/* --- click (metronome) --- */
.click-ctl { position: relative; display: flex; align-items: center; gap: 3px; margin-left: 4px; }
.click-toggle { display: inline-flex; align-items: center; gap: 7px; }
.click-icon {
  /* a little metronome: pyramid body with a pendulum */
  position: relative;
  width: 10px;
  height: 12px;
  background: #8b9198;
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
}
.click-icon::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 2px;
  height: 9px;
  background: #1f2226;
  transform: rotate(18deg);
  transform-origin: bottom center;
}
.click-toggle.on { background: linear-gradient(180deg, #6a4a1c, #432f12); color: #ffe2b8; }
.click-toggle.on .click-icon { background: #ffb347; }
.click-more { font-size: 10px; }

.click-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: max-content;
  padding: 12px 14px;
  border: 1px solid #2c3236;
  border-radius: 6px;
  background: #101315;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
}
.cp-row { display: grid; grid-template-columns: 64px auto auto; align-items: center; gap: 10px; }
.cp-label { font: 700 9px var(--font); letter-spacing: 0.18em; color: var(--rail-dim); }
.cp-range { width: 170px; accent-color: #e0782e; }
.cp-value { min-width: 38px; font: 600 11px var(--mono); color: var(--vfd); text-align: right; }
.cp-row .segmented { grid-column: 2 / -1; justify-self: start; }

.segmented {
  display: inline-flex;
  border: 1px solid #0a0b0c;
  border-radius: 4px;
  overflow: hidden;
}
.segmented button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid #0a0b0c;
  background: linear-gradient(180deg, #3a3e43, #26292d);
  color: #b9bec4;
  font: 700 9px var(--font);
  letter-spacing: 0.14em;
  cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: linear-gradient(180deg, #2f5f57, #1f413b); color: #e4fff8; }

.rail-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #0a0b0c;
  border-radius: 4px;
  background: #2a2d32;
  color: #ecebe6;
  font: 700 10px var(--font);
  letter-spacing: 0.1em;
}

.panic { margin-left: auto; background: linear-gradient(180deg, #7d2a1f, #4f1710); }
.panic:hover { background: linear-gradient(180deg, #8f3326, #5a1b13); }


/* --------------------------------------------------------------- desk tabs */

.desk-tabs {
  position: relative;
  z-index: 30;
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 40px;
  padding: 6px 20px 0;
  background: #121416;
  box-shadow: inset 0 -1px 0 #050506;
  overflow-x: auto;
  scrollbar-width: thin;
  user-select: none;
  -webkit-user-select: none;
}
/* With many desks only the desk tabs scroll: ◀ ▶, + and the MIXER tab stay in view. */
.desk-tab-list { display: flex; align-items: flex-end; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.desk-tab-add, .desk-nav { flex: none; }
/* The MIXER tab: at the right end of the bar (after the hint, which takes the free space). */
.desk-tab-fixed { display: flex; flex: none; align-items: flex-end; }
/* ◀ ▶: previous / next tab (MIDI-learnable). */
.desk-nav { display: flex; align-self: center; gap: 2px; margin-right: 8px; }
.desk-nav-btn {
  width: 26px;
  height: 24px;
  border: 1px solid #2c3236;
  border-radius: 4px;
  background: #15181a;
  color: #8b9198;
  font-size: 9px;
  cursor: pointer;
}
.desk-nav-btn:hover { color: #e9ebee; border-color: #6d747c; background: #1f2226; }
.desk-nav-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.desk-tab {
  position: relative;
  display: flex;
  align-items: center;
  height: 31px;
  margin-bottom: 1px; /* the bar's edge shows under the tabs in the back */
  border: 1px solid #050506;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #24272b, #1b1d20);
  color: #8d949c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.desk-tab:hover { color: #c9cfd5; background: linear-gradient(180deg, #2b2f33, #1f2225); }
.desk-tab.active {
  height: 35px;
  margin-bottom: 0; /* one surface with the desk below */
  background: #2a2d31;
  color: #f0ede5;
  box-shadow: inset 0 2px 0 #e0782e, inset 0 3px 0 rgba(255, 255, 255, 0.06);
}
.desk-tab-main {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 4px 0 14px;
  border: 0;
  background: none;
  color: inherit;
  font: 700 11px var(--font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  touch-action: none;
}
.desk-tab-main:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: 6px; }
.desk-tab:not(:has(.desk-tab-close)) .desk-tab-main { padding-right: 14px; }
.desk-tab-keys { display: none; color: var(--vfd); font-size: 13px; letter-spacing: 0; text-shadow: 0 0 6px var(--vfd-dim); }
.desk-tab.has-keys .desk-tab-keys { display: inline; }
.desk-tab-count {
  min-width: 18px;
  padding: 2px 5px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font: 600 9px var(--mono);
  letter-spacing: 0;
  color: #9aa0a6;
  text-align: center;
}
.desk-tab-count:empty { display: none; }
/* The fixed mixer tab: always first, with a little fader icon. */
.desk-tab-icon { display: none; align-items: flex-end; gap: 2px; height: 12px; }
.desk-tab-icon i { width: 3px; border-radius: 1px; background: currentColor; }
.desk-tab-icon i:nth-child(1) { height: 7px; }
.desk-tab-icon i:nth-child(2) { height: 12px; }
.desk-tab-icon i:nth-child(3) { height: 9px; }
.desk-tab.fixed .desk-tab-icon { display: inline-flex; color: #ffa142; }
.desk-tab.fixed .desk-tab-main { padding-right: 16px; letter-spacing: 0.2em; cursor: pointer; }
.desk-tab.fixed { margin-left: 6px; }
.desk-tab-close {
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #8d949c;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.desk-tab:hover .desk-tab-close, .desk-tab-close:focus-visible { opacity: 1; }
.desk-tab.active .desk-tab-close { opacity: 0.55; }
.desk-tab.active .desk-tab-close:hover, .desk-tab.active .desk-tab-close:focus-visible { opacity: 1; }
.desk-tab-close:hover { background: #4a1d17; color: #ffd2c9; }
.desk-tab.dragging { z-index: 2; cursor: grabbing; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6); }
.desk-tab.drop-target {
  background: #173430;
  color: var(--vfd);
  box-shadow: 0 0 0 2px var(--vfd), 0 0 16px rgba(125, 255, 224, 0.45);
}
.desk-tab-input {
  height: 22px;
  padding: 0 6px;
  border: 1px solid #000;
  border-radius: 3px;
  background: var(--vfd-bg);
  color: var(--vfd);
  font: 600 12px var(--mono);
  letter-spacing: 0.04em;
  text-transform: none;
}
.desk-tab-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.desk-tab-add {
  flex: none;
  align-self: center;
  width: 28px;
  height: 26px;
  margin-left: 2px;
  border: 1px dashed #3d4247;
  border-radius: 5px;
  background: transparent;
  color: #8d949c;
  font: 400 18px/1 var(--font);
  cursor: pointer;
}
.desk-tab-add:hover { color: #e9ebee; border-color: #6d747c; background: #1f2226; }
.desk-tab-add:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.desk-tab-add:disabled { opacity: 0.35; cursor: default; }
/* Balloon tip under a desk tab: how to rename it, and what is on the desk. */
.tab-balloon {
  position: fixed;
  z-index: 75;
  max-width: 280px;
  padding: 8px 12px 9px;
  border-radius: 8px;
  background: #f6f2e6;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.35);
  color: #23262a;
  font: 12px/1.35 var(--font);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
}
.tab-balloon.show { opacity: 1; transform: none; }
.tab-balloon::before {
  /* the arrow up to the tab */
  content: "";
  position: absolute;
  top: -6px;
  left: calc(var(--arrow, 50%) - 6px);
  width: 12px;
  height: 12px;
  background: inherit;
  box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.35);
  transform: rotate(45deg);
}
.tab-balloon b { display: block; font-weight: 700; }
.tab-balloon span { display: block; margin-top: 1px; font-size: 11px; color: #555a60; }
.tab-balloon small {
  display: block;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  font: 600 10px/1.4 var(--mono);
  color: #6b7076;
}
.tab-balloon kbd { background: #fff; border-color: #b9b5aa; color: #23262a; }
@media (prefers-reduced-motion: reduce) { .tab-balloon { transition: none; transform: none; } }

.desk-tabs-hint {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  align-self: center;
  padding-left: 16px;
  overflow: hidden;
  font-size: 11px;
  color: #5f666d;
  white-space: nowrap;
  text-overflow: ellipsis; /* gives way first when the tabs need the room */
}
@media (max-width: 900px) {
  .desk-tabs-hint { display: none; }
  .desk-tab-fixed { margin-left: auto; }
}

/* ------------------------------------------------------------ desk surface */

/* Middle-button drag pans the view (ui/pan.js). */
.desk-view.panning, .desk-view.panning * { cursor: grabbing !important; }
.desk-view {
  position: relative;
  flex: 1;
  overflow: auto;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #2a2d31, #1c1e21);
}

.boot {
  display: grid;
  place-items: center;
  height: 100%;
  font: 600 13px var(--mono);
  color: var(--vfd);
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px var(--vfd-dim);
}
.boot.error { color: #ff8a7a; text-shadow: none; }

.desk-surface {
  position: relative;
  width: max-content;
  margin-inline: auto; /* centred while it fits, scrollable when it does not */
}
/* Desks out of view keep running (and keep their layout, so they can be
   measured) but take no room and catch no pointer. */
.desk-surface:not(.active) {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

/* A stacking layer of its own: the devices' z-indexes (raised each time one is touched) order them
   among themselves only, so the cables always run above all of them. */
.desk-devices { position: relative; z-index: 0; }

.device-slot {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.device-slot.moving { filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.45)); }
.device-slot.leaving { opacity: 0.45; }
.device-slot.screwed .device-tab { display: none; } /* the patchbay is screwed on: nothing to grab */

.device-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 22px;
  padding: 0 4px;
  font: 700 10px var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8d949c;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.device-tab::before {
  /* grip dots: the tab is the handle for moving the device */
  content: "";
  width: 10px;
  height: 12px;
  background: radial-gradient(circle, #6d747c 1.2px, transparent 1.6px) 0 0 / 5px 4px;
  opacity: 0.8;
}
.device-slot.moving .device-tab { cursor: grabbing; color: #c9cfd5; }
.device-tab-keys {
  display: none;
  padding: 2px 7px;
  border-radius: 3px;
  background: #173430;
  color: var(--vfd);
  font-size: 9px;
  letter-spacing: 0.12em;
}
.is-keyboard-target .device-tab-keys { display: inline-block; }
.device-tab-tools { display: flex; gap: 2px; margin-left: auto; }
.device-tab-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #8d949c;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.device-slot:hover .device-tab-btn, .device-tab-btn:focus-visible { opacity: 1; }
.device-tab-move:hover, .device-tab-expander:hover { background: #1d2a2d; color: var(--vfd); }
/* ⌨ off (an expander): shown all the time, struck through. */
.device-tab-expander[aria-pressed="false"] { opacity: 1; color: #ffb35c; text-decoration: line-through; }
.device-tab-remove:hover { background: #4a1d17; color: #ffd2c9; }

.move-menu {
  position: fixed;
  z-index: 70;
  min-width: 180px;
  padding: 6px;
  border: 1px solid #2c3236;
  border-radius: 6px;
  background: #101315;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
}
.move-menu-title { padding: 4px 8px 6px; font: 700 9px var(--font); letter-spacing: 0.2em; color: #6f9a92; }
.move-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #e6e8ea;
  font: 700 12px var(--font);
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
}
.move-item:hover, .move-item:focus-visible { background: #1d2a2d; outline: none; }
.move-item.new { color: #9fb8b2; }

.device { user-select: none; -webkit-user-select: none; touch-action: manipulation; }

/* -------------------------------------------------------------------- jacks */

ws-jack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.jack-label {
  font: 700 8px/1 var(--font);
  letter-spacing: 0.1em;
  color: var(--ink);
  white-space: nowrap;
}
.jack-socket {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  transition: box-shadow 0.12s;
}
.jack-socket:active { cursor: grabbing; }
.jack-socket svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.j-bezel { fill: #b7bbc0; stroke: #5d6166; stroke-width: 1; }
.j-hole { fill: #0b0b0b; stroke: #2e2e2e; stroke-width: 1; }
.j-pin { fill: #d2ae55; }
.j-notch { fill: #0b0b0b; }
.j-nut { fill: #c5c9cd; stroke: #6c7075; stroke-width: 1; }
.j-collar { fill: #8f949a; stroke: #565a5e; stroke-width: 1; }

.jack-led {
  position: absolute;
  top: -2px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a1309;
  box-shadow: 0 0 0 1px #111;
}
.jack-audio .jack-led { display: none; }
ws-jack.active .jack-led { background: #ff6a2a; box-shadow: 0 0 0 1px #111, 0 0 7px 2px rgba(255, 106, 42, 0.75); }

ws-jack.compatible .jack-socket { box-shadow: 0 0 0 3px rgba(125, 211, 255, 0.45), 0 0 14px 2px rgba(125, 211, 255, 0.45); }
ws-jack.hover .jack-socket { box-shadow: 0 0 0 4px #7dd3ff, 0 0 20px 4px rgba(125, 211, 255, 0.8); }

/* ------------------------------------------------------------------ cables */

.desk-cables {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  overflow: visible;
  pointer-events: none;
}
.cable-shadow { fill: none; stroke: rgba(0, 0, 0, 0.32); stroke-width: 9; stroke-linecap: round; filter: blur(3px); }
.cable-body { fill: none; stroke-width: 7; stroke-linecap: round; pointer-events: stroke; cursor: pointer; transition: stroke-width 0.1s; }
.cable-shine { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 1.6; stroke-linecap: round; transform: translate(-1px, -2px); pointer-events: none; }
.cable:hover .cable-body { stroke-width: 9; }
.cable.offline { opacity: 0.35; filter: grayscale(1); }
.plug { fill: #2b2d30; stroke: #0d0e0f; stroke-width: 1.5; }
.plug-cap { stroke: rgba(0, 0, 0, 0.45); stroke-width: 1; }
.cables { transition: opacity 0.2s; }
.drag-layer .cable-body { pointer-events: none; }

.desk-cables[data-mode="fade"] .cables:not(.drag-layer) { opacity: 0.2; }
.desk-cables[data-mode="fade"] .cable-body { pointer-events: none; }
.desk-cables[data-mode="hide"] .cables:not(.drag-layer) { display: none; }
.desk-cables.dragging .cables:not(.drag-layer) { opacity: 0.45; }

/* ------------------------------------------------------------------- footer */

.help {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 24px;
  padding: 8px 20px;
  border-top: 1px solid #050506;
  background: #17191c;
  font-size: 12px;
  color: #9aa0a6;
}
.help-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.help b { color: #e6e1d6; font-weight: 600; }
.keys-desk { color: #9aa0a6; }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid #44484d;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #22252a;
  color: #e6e1d6;
  font: 600 11px var(--mono);
  text-align: center;
}

/* ------------------------------------------------------------------ dialogs */

.dialog {
  width: min(92vw, 360px);
  padding: 20px;
  border: 1px solid #333a38;
  border-radius: 8px;
  background: #121514;
  color: #e9e6de;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.dialog h3 { margin: 0 0 14px; font: 700 13px var(--font); letter-spacing: 0.2em; text-transform: uppercase; }
.dialog p { margin: 0 0 16px; line-height: 1.45; }
.dialog label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font: 700 10px var(--font);
  letter-spacing: 0.14em;
  color: #9fa9a6;
}
.dialog input, .dialog select {
  padding: 8px 10px;
  border: 1px solid #36403d;
  border-radius: 4px;
  background: #070908;
  color: var(--vfd);
  font: 500 14px var(--mono);
  letter-spacing: 0;
}
.dialog input:focus, .dialog select:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.dialog-error { min-height: 1.2em; margin: 0 0 8px !important; color: #ff8a7a; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog button {
  padding: 8px 14px;
  border: 0;
  border-radius: 4px;
  font: 700 11px var(--font);
  letter-spacing: 0.1em;
  cursor: pointer;
}
.btn-primary { background: #2d5fae; color: #fff; }
.btn-danger { background: #b8321f; color: #fff; }
.btn-secondary { background: #2a2f2e; color: #e6e1d6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  z-index: 80;
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border: 1px solid #23413a;
  border-radius: 6px;
  background: #0b1513;
  color: var(--vfd);
  font: 600 12px var(--mono);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: #ffb0a3; border-color: #5c2a22; background: #1a0d0b; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* A device taken offline (being reworked), on the desk of a user who is not an
   admin: a grey area its size, DEVICE UNAVAILABLE, its cables' jacks below. */
.unavailable {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  border: 3px dashed #7a8188;
  border-radius: 12px;
  background: repeating-linear-gradient(135deg, #43474c 0 18px, #3b3f44 18px 36px);
  color: #c9cdd2;
  overflow: hidden;
  container-type: size; /* the message grows with the area (a big synth's or a small pedal's) */
}
.unavailable-msg { display: flex; flex-direction: column; align-items: center; gap: 0.6em; max-width: 70cqw; text-align: center; }
.unavailable-msg b {
  padding: 0.35em 0.8em;
  border-radius: 6px;
  background: rgba(20, 22, 25, 0.72);
  font: 700 clamp(14px, 3.4cqw, 44px) var(--mono);
  letter-spacing: 0.2em;
  color: #eceef0;
}
.unavailable-msg span { font: 500 clamp(11px, 1.3cqw, 17px)/1.45 var(--font); color: #d7dade; text-shadow: 0 1px 2px #000; }
.unavailable-jacks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(20, 22, 25, 0.6);
}
.unavailable-jacks:empty { display: none; }

/* Admins see the devices they took offline marked on their desks. */
.device-tab-offline {
  display: none;
  padding: 2px 7px;
  border-radius: 3px;
  background: #4a3512;
  color: #ffcf7a;
  font-size: 9px;
  letter-spacing: 0.12em;
}
.is-offline .device-tab-offline { display: inline-block; }
