/* ── Toolbar ─────────────────────────────────────────── */
.tb {
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px; min-height: 56px;
  background: var(--s1); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tb-ctx {
  display: none;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tb-ctx.on { display: flex; }
/* Tabs without a toolbar context (e.g. Rig Analysis) collapse the whole row. */
.tb:not(:has(.tb-ctx.on)) { display: none; }
.tb .cues-tb {
  flex: 1;
  min-width: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}
.stat { font-size: 14px; color: var(--muted); }
.stat b { color: var(--text); font-weight: 600; }

/* Primary nav: tabs in their own row, anchored left.
   Tabs decide everything visible below; they get top billing.
   The old right-aligned, button-styled tabs lost to "Add Fixture" — not anymore. */
.tabnav {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 16px;
  background: var(--s2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tabnav .tab {
  padding: 13px 20px 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
  margin-bottom: -1px;
  user-select: none;
  background: transparent;
}
.tabnav .tab:hover { color: var(--text); }
/* Tabs switched off in the View menu. */
.tabnav .tab.tab-off { display: none; }
.tabnav .tab.on {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent);
  background: transparent;
}

/* Workflow step badges (1 Stage & Rig · 2 Design · 3 Cues) */
.tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-right: 7px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--s1);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: -2px;
  transition: background .12s, color .12s, border-color .12s;
}
.tabnav .tab.on .tab-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tabnav .tab:hover .tab-num { border-color: var(--accent); }

/* Pushes the detail views to the right edge. */
.tabnav-spacer { margin-left: auto; }

/* Detail views (Patch, Output) — reachable but visually secondary. */
.tabnav .tab.tab-detail {
  font-size: 13px;
  font-weight: 500;
  opacity: .72;
  padding-top: 14px;
}
.tabnav-spacer + .tab.tab-detail {
  border-left: 1px solid var(--border);
  margin-left: 12px;
  padding-left: 18px;
}
.tabnav .tab.tab-detail:hover,
.tabnav .tab.tab-detail.on { opacity: 1; }
.tabnav .tab.tab-detail.on { font-weight: 600; }

/* Legacy tabs container — hidden; tabs moved to .tabnav. */
.tabs { display: none; }

/* ── Panels ──────────────────────────────────────────── */
main { flex: 1; overflow: hidden; position: relative; min-height: 0; }
.panel { position: absolute; inset: 0; display: none; flex-direction: column; overflow: hidden; }
.panel.on { display: flex; }

/* ── Selection context bar ───────────────────────────── */
.sel-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 22px;
  background: rgba(99,102,241,.1); border-bottom: 1px solid rgba(99,102,241,.25);
  flex-shrink: 0;
}
.sel-bar.hidden { display: none; }
.sel-bar-text { font-size: 14px; color: var(--accent); font-weight: 600; }

/* ── Channel grid ────────────────────────────────────── */
.ch-grid {
  flex: 1; overflow-y: auto; padding: 16px 22px;
  display: grid; grid-template-columns: repeat(auto-fill, 72px);
  gap: 7px; align-content: start;
}
.ch-grid.hidden { display: none; }

/* ── Output universe tab strip ───────────────────────── */
.output-univ-tabs {
  display: flex; gap: 6px;
  padding: 8px 22px 0;
  flex-shrink: 0;
}
.output-univ-tabs.hidden { display: none; }
.output-univ-tab {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 5px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: color .15s, background .15s, border-color .15s;
}
.output-univ-tab:hover { color: var(--text); background: rgba(99,102,241,.08); }
.output-univ-tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }

#gridsUx .cell { cursor: default; }

/* ── Cell ────────────────────────────────────────────── */
.cell {
  width: 72px; height: 88px;
  background: var(--s1); border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
  padding: 6px 4px 5px; position: relative; overflow: hidden;
  transition: border-color .15s, background .15s;
  user-select: none; -webkit-user-select: none;
}
.cell:hover { border-color: rgba(99,102,241,.5); }
.cell.sel   { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Fill bar — color set per channel type in JS */
.cell-bg {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--green); opacity: .15; pointer-events: none;
  transition: height .05s linear;
}

.cell-num {
  font-size: 11px; color: var(--muted); font-weight: 700; z-index: 1; line-height: 1; align-self: flex-start; padding-left: 2px;
}

/* Icon area */
.cell-icon {
  flex: 1; display: flex; align-items: center; justify-content: center;
  z-index: 1; width: 100%;
}
.icon-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(128,128,128,.15);
  transition: background .06s linear, box-shadow .06s linear;
}
.icon-sym {
  font-size: 20px; line-height: 1; transition: opacity .06s linear;
}
.icon-bar {
  width: 10px; height: 28px; border-radius: 5px;
  background: linear-gradient(to top, #facc15, #fef08a);
  transform-origin: bottom; transition: transform .06s linear; transform: scaleY(0);
}

.cell-v {
  font-size: 18px; font-weight: 700; color: var(--text);
  z-index: 1; font-variant-numeric: tabular-nums; line-height: 1; margin-top: 1px;
}

.cell-overlap {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(99, 102, 241, 0.65);
  color: #e0e7ff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.cell-overlap.hidden { display: none; }

/* ── Patch list ─────────────────────────────────────── */
.fx-scroll { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.fx-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 10px; color: var(--muted); text-align: center; min-height: 200px; font-size: 14px; }
.fx-empty h3 { font-size: 18px; color: var(--text); }
.fx-card {
  background: var(--s1); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.fx-card:not(.fx-open) > .fx-body { display: none; }
.fx-card-hd {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--s2);
  border-bottom: 1px solid transparent; cursor: pointer; user-select: none;
}
.fx-card.fx-open > .fx-card-hd {
  border-bottom: 1px solid var(--border);
}
.fx-expand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: none; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 6px; flex-shrink: 0;
}
.fx-expand:hover { background: rgba(99,102,241,.14); color: var(--text); }
.fx-chevron { width: 18px; height: 18px; transition: transform .15s ease; }
.fx-card:not(.fx-open) .fx-chevron { transform: rotate(-90deg); }
.fx-channel-phys {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255,255,255,.02);
  margin-bottom: 10px;
}
.fx-channel-phys:last-child { margin-bottom: 0; }
.fx-channel-phys-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.fx-channel-phys-name {
  color: var(--text);
  font-weight: 600;
}
.fx-name { font-weight: 700; font-size: 15px; letter-spacing: .1px; }
.fx-hd-summary { font-size: 12px; color: var(--muted); font-weight: 500; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 5px; background: var(--border); color: var(--muted); font-weight: 500; }
.badge.addr { color: var(--accent); background: rgba(99,102,241,.14); }
.fx-meta {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end;
  padding: 12px 16px 14px; background: rgba(0,0,0,.14);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.fx-addr-field { display: flex; flex-direction: column; gap: 4px; }
.fx-addr-field label {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.fx-addr-field input {
  width: 76px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--s1); color: var(--text); font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.fx-meta-hint { color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.fx-meta-name-field {
  flex: 1 1 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fx-meta-name-field label {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.fx-meta-name-input {
  width: 100%;
  max-width: 400px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--s1);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  box-sizing: border-box;
}
.fx-meta-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.fx-notes-field {
  flex: 1 1 220px; min-width: 180px; display: flex; flex-direction: column; gap: 4px;
}
.fx-notes-field label {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.fx-notes-field textarea {
  min-height: 52px; max-height: 140px; resize: vertical;
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--s1); color: var(--text); font-family: inherit; font-size: 13px; line-height: 1.4;
}
.fx-rows { display: flex; flex-direction: column; }
.fx-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1.35fr) minmax(88px, 1fr) 52px auto;
  align-items: center; gap: 10px 14px;
  padding: 10px 16px; cursor: pointer; border-bottom: 1px solid rgba(40,40,74,.5); transition: background .1s;
}
.fx-row:last-child { border-bottom: none; }
.fx-row:hover { background: var(--s2); }
.fx-row.sel   { background: #1c1c40; }
.fx-row-mid { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.fx-ch-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.fx-ch-num { font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.fx-ch-fn { font-size: 14px; font-weight: 600; }
.fx-ch-type-pill {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 4px; background: rgba(99,102,241,.12); color: var(--muted);
  flex-shrink: 0;
}
.fx-ch-desc {
  font-size: 12px; color: var(--muted); line-height: 1.4;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.fx-ch-desc:empty { display: none; }
.fx-bar-wrap { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; align-self: center; }
.fx-bar { height: 100%; border-radius: 4px; width: 0%; background: var(--accent); transition: width .05s linear; }
.fx-ch-val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; align-self: center; }
.fx-ch-midi-btn {
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--s1); color: var(--muted);
  cursor: pointer; align-self: center; flex-shrink: 0; white-space: nowrap;
  transition: background .1s, color .1s, border-color .1s;
}
.fx-ch-midi-btn:hover { background: var(--s2); color: var(--text); }
.fx-ch-midi-btn.mapped {
  background: rgba(99,102,241,.18); color: #c7d2fe; border-color: rgba(99,102,241,.55);
}
.fx-ch-midi-btn.mapped:hover { background: rgba(99,102,241,.28); }
.fx-ch-midi-btn.recording {
  background: rgba(239,68,68,.22); color: #fecaca; border-color: rgba(239,68,68,.55);
  animation: fx-ch-midi-rec 1s ease-in-out infinite;
}
@keyframes fx-ch-midi-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.fx-hd-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.fx-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 32px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--s1); color: var(--text); cursor: pointer; flex-shrink: 0;
}
.fx-icon-btn:hover { background: var(--s2); filter: brightness(1.05); }
.fx-icon-btn.danger {
  color: #fca5a5; border-color: rgba(239,68,68,.35);
}
.fx-icon-btn.danger:hover { background: rgba(239,68,68,.12); }
.fx-icon-btn svg { width: 18px; height: 18px; display: block; }

/* ── Patch: Finder-style views (icons / list / stage) ── */
#panel-patch.panel { flex-direction: column; }
.patch-view-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.patch-view-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.patch-view-pane.hidden { display: none !important; }
.patch-view-toggles {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border);
}
.patch-view-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.patch-view-toggle:hover { color: var(--text); background: rgba(99, 102, 241, 0.12); }
.patch-view-toggle.on {
  background: var(--accent);
  color: #fff;
}
.patch-view-toggle svg { width: 18px; height: 18px; display: block; }

.fx-list-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 22px 18px; }
.fx-list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fx-list-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--s1);
  z-index: 1;
}
.fx-list-table th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}
.fx-list-table th[data-sort-key]:hover { color: var(--text); }
.fx-sort-ind {
  display: inline-block;
  min-width: 12px;
  margin-left: 6px;
  color: var(--muted);
  font-size: 10px;
}
.fx-list-table th.sort-asc .fx-sort-ind,
.fx-list-table th.sort-desc .fx-sort-ind {
  color: var(--accent);
}
.fx-list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(40, 40, 74, 0.55);
  vertical-align: middle;
}
.fx-list-table tr.fx-list-row:hover td { background: rgba(99, 102, 241, 0.06); }
.fx-list-table tr.fx-list-row { cursor: pointer; }
.fx-list-name { font-weight: 600; }
.fx-list-actions { text-align: right; white-space: nowrap; }
.fx-list-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}
.fx-list-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  padding: 48px;
  text-align: center;
}
.fx-list-empty.hidden { display: none !important; }

.patch-stage-pane { padding: 12px 22px 18px; overflow-x: hidden; overflow-y: auto; }
.patch-stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}
.patch-stage-plot-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.patch-stage-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
}
.patch-stage-floor {
  flex: 0 0 auto;
  flex-shrink: 0;
  position: relative;
  min-width: 280px;
  min-height: 200px;
  background: linear-gradient(165deg, rgba(35, 38, 68, 0.95) 0%, rgba(18, 20, 40, 0.98) 100%);
  border: 2px solid rgba(99, 102, 241, 0.35);
  border-radius: 12px;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.patch-stage-dims {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 5;
  font-size: 11px;
  color: rgba(199, 210, 254, 0.85);
  background: rgba(18, 20, 40, 0.75);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  pointer-events: none;
  white-space: nowrap;
}
.patch-stage-dims:empty { display: none; }
.patch-stage-resize-corner {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 50;
  border-radius: 10px 0 10px 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    transparent 45%,
    rgba(99, 102, 241, 0.35) 45%,
    rgba(99, 102, 241, 0.55) 100%
  );
  border-top: 1px solid rgba(99, 102, 241, 0.35);
  border-left: 1px solid rgba(99, 102, 241, 0.35);
  box-sizing: border-box;
}
.patch-stage-resize-corner:hover {
  background: linear-gradient(
    135deg,
    transparent 0%,
    transparent 40%,
    rgba(129, 140, 248, 0.45) 40%,
    rgba(99, 102, 241, 0.65) 100%
  );
}
.patch-stage-floor::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 18%;
  bottom: 12%;
  border: 1px dashed rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  pointer-events: none;
}
.patch-stage-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 0;
}
.patch-stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 2px 0 10px;
  flex-shrink: 0;
}
.patch-stage-filter {
  flex: 1;
  min-width: 120px;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--text);
  font-size: 13px;
}
.patch-stage-ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.patch-stage-ctl select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--text);
  font-size: 12px;
}
.patch-stage-stat {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
  max-width: 220px;
}
.patch-stage-viewport {
  position: absolute;
  /* Margin keeps units placed at the plot edges (x/y = 0 or 1) fully
     visible — chips are centered on their coordinate. */
  inset: 34px 38px 38px;
  z-index: 1;
}
.patch-stage-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  --sgd: 24;
  background-image:
    linear-gradient(to right, rgba(165, 180, 252, 0.35) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(165, 180, 252, 0.35) 1px, transparent 1px);
  background-size: calc(100% / var(--sgd)) calc(100% / var(--sgd));
}
.stage-fx-modal { max-width: 520px; width: 92vw; }
.stage-fx-modal-scroll {
  max-height: min(68vh, 560px);
  overflow-y: auto;
  padding: 2px 0 12px;
}
.stage-fx-modal-ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.stage-fx-modal-hint { font-size: 12px; color: var(--muted); }
.patch-stage-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  min-width: 92px;
  max-width: 160px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--s2);
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 2;
  user-select: none;
  text-align: center;
}
.patch-stage-chip.dimmed {
  opacity: 0.22;
  pointer-events: none;
}
/* Plot-style unit: universe/address label, type symbol, boxed channel —
   mirrors how units are annotated on a printed light plot. */
.patch-stage-chip.fx-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 2px 3px;
  border: none;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  transition: transform 0.15s ease-out;
}
.patch-stage-chip.fx-circle:hover {
  transform: translate(-50%, -50%) scale(1.12);
  z-index: 21 !important;
}
.fx-unit-addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(10, 12, 18, 0.72);
  border-radius: 3px;
  padding: 1px 3px;
  white-space: nowrap;
  pointer-events: none;
}
.fx-unit-icon {
  width: 26px;
  height: 26px;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.fx-unit-icon svg { width: 100%; height: 100%; display: block; }
.fx-unit-chrow {
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
.fx-unit-ch {
  display: block;
  color: #f3f4f6;
  font-size: 11px;
  font-weight: 700;
  padding: 1.5px 5px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: rgba(10, 12, 18, 0.82);
  white-space: nowrap;
}
.fx-unit-grp {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8.5px;
  color: var(--muted);
  background: rgba(10, 12, 18, 0.72);
  border-radius: 3px;
  padding: 1px 3px;
  white-space: nowrap;
}
.patch-stage-chip.fx-circle.selected {
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 4px 12px rgba(0, 0, 0, 0.5);
  filter: none;
  z-index: 22 !important;
}
.patch-stage-chip.fx-circle.selected .fx-unit-ch {
  background: #ffffff;
  color: #111827;
  border-color: #ffffff;
}
.patch-stage-chip.fx-circle.same-group {
  filter: none;
  opacity: 0.95;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.patch-stage-chip--compact.fx-circle { padding: 1px 2px; }
.patch-stage-chip--compact.fx-circle .fx-unit-icon { width: 20px; height: 20px; }
.patch-stage-chip--compact.fx-circle .fx-unit-addr { font-size: 8px; }
.patch-stage-chip--compact.fx-circle .fx-unit-ch { font-size: 9.5px; padding: 1px 4px; }
.patch-stage-chip-circle-number {
  color: inherit;
}
.patch-grid-detail-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--s1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
}
.patch-grid-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.patch-grid-detail-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.patch-grid-detail-header .btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  flex-shrink: 0;
}
.patch-grid-detail-body {
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 12px;
  flex: 1;
}
.patch-grid-detail-section {
  margin-bottom: 16px;
}
.patch-grid-detail-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.patch-grid-detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--s2);
}
.patch-grid-detail-hero-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.patch-grid-detail-hero-value {
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
}
.patch-grid-detail-hero-sub {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.patch-grid-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
}
.patch-grid-detail-label {
  color: var(--muted);
  flex-shrink: 0;
}
.patch-grid-detail-value {
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.patch-grid-detail-group-item {
  display: inline-block;
  padding: 4px 8px;
  margin: 2px 2px 2px 0;
  background: var(--s2);
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}
.patch-grid-detail-group-item:hover {
  background: var(--s3);
  box-shadow: 0 0 0 2px var(--accent);
}
.patch-stage-chip--compact {
  min-width: 52px;
  max-width: 92px;
  padding: 4px 6px;
  font-size: 10px;
}
.patch-stage-chip--compact .patch-stage-chip-name { font-size: 10px; }
.patch-stage-chip--compact .patch-stage-chip-sub { display: none; }
.patch-stage-chip:active { cursor: grabbing; z-index: 20; }
.patch-stage-chip-name {
  font-weight: 700;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.patch-stage-chip-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }
.patch-stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.patch-stage-empty.hidden { display: none !important; }

/* ── Output Channel View (Nomad/EOS-style) ───────────────────────────────── */
#outputChannelView {
  flex: 1; overflow-y: auto; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 22px;
}
#outputChannelView.hidden { display: none; }

.ocv-empty {
  color: var(--muted); font-size: 14px; text-align: center; padding: 48px;
}
.ocv-empty-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin: auto;
}
/* Banner over the raw channel grid while nothing is patched */
.output-empty-hint {
  margin: 10px 18px 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--s1);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.output-empty-hint.hidden { display: none; }
.ocv-empty-msg { max-width: 380px; line-height: 1.5; }
.ocv-empty-actions { display: flex; gap: 8px; }

/* Fixture type group */
.ocv-group { display: flex; flex-direction: column; }

.ocv-group-hd {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 0 2px 5px;
}

/* Table */
.ocv-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  table-layout: auto;
}

/* Section header row */
.ocv-sec-row th {
  text-align: center; font-size: 10px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  padding: 3px 6px 2px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ocv-ch-col {
  text-align: left !important; padding-left: 4px !important;
  color: var(--muted) !important; min-width: 32px;
}
.ocv-sec-th            { color: var(--muted); }
.ocv-sec-th.ocv-sec-intens { color: #fb7185; }
.ocv-sec-th.ocv-sec-focus  { color: #22d3ee; }
.ocv-sec-th.ocv-sec-color  { color: #a78bfa; }
.ocv-sec-th.ocv-sec-beam   { color: #94a3b8; }
.ocv-sec-th.ocv-sec-other  { color: var(--muted); }

/* Parameter name row */
.ocv-param-row th {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-align: center; padding: 2px 8px 5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

/* Section separator: left border on first col of each section */
.ocv-sec-border { border-left: 1px solid var(--border) !important; }

/* Data rows */
.ocv-row { border-bottom: 1px solid rgba(255,255,255,.04); }
.ocv-row:hover { background: rgba(99,102,241,.07); }
.ocv-row.hidden { display: none; }

.ocv-ch {
  font-size: 14px; font-weight: 700; color: var(--text);
  padding: 5px 12px 5px 4px; white-space: nowrap; min-width: 36px;
}

.ocv-val {
  text-align: center; padding: 5px 8px;
  font-size: 12px; font-weight: 600;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; min-width: 44px;
}

/* Inactive fixture tiles */
.ocv-inactive {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 7px 2px 2px;
}
.ocv-tile {
  width: 36px; height: 36px;
  background: var(--s1); border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted-2);
}
.ocv-tile.hidden { display: none; }

/* Toolbar toggle button active state */
#ocvToggleBtn.on {
  background: rgba(99,102,241,.15);
  border-color: var(--accent); color: var(--accent);
}


/* ── Purpose columns + editor (Patch tab) ─────────────────────────────── */

.fx-sel-th, .fx-sel-cell { width: 28px; text-align: center; }
.fx-sel-cell input, .fx-sel-th input { cursor: pointer; accent-color: var(--accent); }

.fx-purpose-cell { cursor: pointer; max-width: 220px; }
.fx-purpose-cell:hover { background: var(--s2); }
.fx-purpose-empty { color: var(--muted-2); }
.fx-purpose-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.45);
  white-space: nowrap;
}
/* Inferred (unreviewed) values render dashed; manual ones solid. */
.fx-purpose-chip--inferred { border-style: dashed; opacity: .85; }
.fx-purpose-chip--mixed {
  color: var(--muted);
  background: var(--s2);
  border-color: var(--border);
}
.fx-purpose-cov { margin-left: 6px; font-size: 11px; color: var(--muted); }
.fx-purpose-suggest { font-size: 11.5px; color: var(--muted); font-style: italic; }
.fx-purpose-accept { margin-left: 6px; }

.patch-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin: 0 0 6px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(99,102,241,.08);
}
.patch-bulk-bar.hidden { display: none; }
.patch-bulk-count { font-size: 12.5px; color: var(--text); }

.purpose-editor {
  position: fixed;
  z-index: 1200;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--s1);
  box-shadow: 0 10px 32px rgba(0,0,0,.5);
}
.purpose-editor-head { display: flex; flex-direction: column; gap: 2px; }
.purpose-editor-title { font-size: 13px; font-weight: 700; }
.purpose-editor-sub { font-size: 11.5px; color: var(--muted); }
.purpose-editor label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: var(--muted);
}
.purpose-editor-hint { font-size: 10.5px; color: var(--muted-2); }
.purpose-editor input, .purpose-editor textarea {
  background: var(--bg2, rgba(0,0,0,.25));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  resize: vertical;
}
.purpose-editor-actions { display: flex; justify-content: flex-end; gap: 6px; }

.patch-groups-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 8px;
}
.patch-groups-bar .hint { font-size: 12px; color: var(--muted); }

/* Design-facing purpose description under the chip (Groups view). */
.fx-purpose-desc {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
