/* Signal chain (FxRackView / FxChainView): TONELAB modules on design tokens (ui/tokens.css).
   Geometry: a module is 262px tall; endpoint panels and lane rows match it so the A → B cable and
   the junction buttons line up. FxRackView.layout() reads .fx-slot offsets, keep them in the flow. */

.fx-help { margin: 0 0 var(--tl-space-3); color: var(--tl-text-muted); font-size: var(--tl-fs-xs); }

/* Rack controls above the canvas. */
.fx-rack-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: var(--tl-space-3); font-size: var(--tl-fs-xs); }
.fx-rack-status { color: var(--tl-text-muted); font: 500 var(--tl-fs-2xs) var(--tl-font-mono); letter-spacing: .04em; }
.fx-rack-status.is-clipping { color: var(--tl-danger); text-shadow: 0 0 8px var(--tl-danger); }

/* The canvas: endpoints never scroll, only the lanes between them. */
.fx-rack { position: sticky; top: calc(var(--tl-topbar-height) + 12px); z-index: 2; display: grid; grid-template-columns: 168px minmax(0, 1fr) 168px;
  --rack-gap: 10px; align-items: start; gap: var(--rack-gap); max-width: 100%; padding: 0 12px; border: 1px solid var(--tl-border-subtle); border-radius: var(--tl-radius-xl);
  background: var(--tl-rack-bg);
  box-shadow: var(--tl-shadow-panel); }
.fx-rack [hidden] { display: none !important; }
.fx-endpoints { display: flex; flex-direction: column; gap: 40px; min-width: 0; }
.fx-endpoint-cell { display: flex; align-items: center; height: 294px; }
.fx-endpoint-cell > .fx-endpoint { width: 100%; }
.fx-scroll { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--tl-border-strong) transparent; }
.fx-track { position: relative; width: max-content; min-width: 100%; }
.fx-chain { display: flex; align-items: center; gap: 0; min-height: 294px; padding: 16px 12px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.fx-track > .fx-chain { position: relative; box-sizing: border-box; width: max-content; min-width: 100%; height: 294px; overflow: visible; }

/* IN / OUT endpoint modules. */
.fx-endpoint { position: relative; display: flex; flex-direction: column; gap: var(--tl-space-2); box-sizing: border-box; height: 262px; min-width: 0; --pad: 10px; padding: var(--pad);
  border: 1px solid var(--tl-border); border-radius: var(--tl-radius-lg); background: var(--tl-surface-1); box-shadow: var(--tl-shadow-module); font-size: var(--tl-fs-xs); }
.fx-endpoint-head { display: grid; grid-template-columns: 28px minmax(0, 1fr) 7px; align-items: center; gap: 9px; flex: none; min-height: 48px; margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 0; padding: 0 12px;
  border-bottom: 1px solid var(--tl-border); border-radius: var(--tl-radius-lg) var(--tl-radius-lg) 0 0; background: var(--tl-surface-4); }
.fx-endpoint-badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: var(--tl-accent); background: var(--tl-accent-tint-strong); font: 600 8px var(--tl-font-mono); }
.fx-endpoint-titles { display: flex; flex-direction: column; min-width: 0; }
.fx-endpoint-titles small { color: var(--tl-text-muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.fx-endpoint-titles strong { margin-top: 3px; overflow: hidden; color: var(--tl-text); font-size: var(--tl-fs-sm); white-space: nowrap; text-overflow: ellipsis; }
/* Status LED: lit while the endpoint carries signal (above the -60 dBFS meter floor). */
/* A muted lane: a tag in its endpoint heads and its effects dimmed (still editable). */
.fx-endpoint-muted { margin-left: 5px; padding: 1px 5px; border: 1px solid color-mix(in srgb, var(--tl-danger) 50%, transparent); border-radius: var(--tl-radius-pill); color: var(--tl-danger); background: var(--tl-danger-tint);
  font: 600 8px var(--tl-font-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.fx-chain.is-muted > * { opacity: .4; filter: saturate(.35); transition: opacity .15s, filter .15s; }
.fx-chain.is-muted > *:hover, .fx-chain.is-muted > *:focus-within { opacity: .75; }
.fx-endpoint-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tl-text-faint); transition: background .15s, box-shadow .15s; }
.fx-endpoint.has-signal .fx-endpoint-dot { background: var(--tl-accent); box-shadow: 0 0 8px var(--tl-accent-glow); }
.fx-endpoint label { min-width: 0; color: var(--tl-text-2); }
.fx-endpoint [hidden] { display: none; }
.fx-select-label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.fx-endpoint-routing { display: flex; flex-direction: column; justify-content: center; flex-shrink: 0; height: 30px; }
/* Big centred knob: label above the dial, value below. */
.fx-endpoint .fx-gain { align-self: center; gap: 4px; margin-top: auto; font-size: var(--tl-fs-2xs); }
.fx-endpoint .fx-gain::part(label) { order: -1; font-weight: 500; }
.fx-endpoint .fx-gain::part(dial) { width: 50px; height: 50px; }
.fx-endpoint-reset { flex: none; margin-top: auto; border-color: var(--tl-border); color: var(--tl-text-muted); font-size: var(--tl-fs-2xs); }
.fx-endpoint-reset:hover { border-color: var(--tl-border-hover); color: var(--tl-text-1); }
/* Output: horizontal pan, then Reset + Mute. */
.fx-endpoint-pan { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 5px; flex: none; padding: 0 2px; }
.fx-endpoint-pan span { margin-right: 3px; color: var(--tl-text-muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.fx-endpoint-pan b { color: var(--tl-text-faint); font: 500 8px var(--tl-font-mono); }
.fx-endpoint-pan tl-slider { min-width: 0; }
.fx-endpoint-actions { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px; flex: none; margin-top: auto; }
.fx-endpoint-actions .fx-endpoint-reset { margin: 0; }
.fx-endpoint-actions .fx-lane-enable { justify-content: flex-start; gap: 6px; padding: 0 8px; border-color: var(--tl-border); color: var(--tl-text-muted); font-size: var(--tl-fs-2xs); }
.fx-lane-enable strong { margin-left: auto; font: 600 8px var(--tl-font-mono); text-transform: uppercase; }
/* Stereo L/R meters: label, bar, reading. The reading column is fixed (longest is "-59.9") so bars don't shift. */
.fx-endpoint-meters { display: grid; gap: 7px; flex: none; padding: 0 2px; }
.fx-endpoint-meters > div { display: grid; grid-template-columns: 9px minmax(0, 1fr) 5ch; align-items: center; gap: 6px; }
.fx-endpoint-meters span { color: var(--tl-text-faint); font: 500 8px var(--tl-font-mono); }
.fx-endpoint-meters output { color: var(--tl-text-2); font: 500 var(--tl-fs-2xs) var(--tl-font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.fx-hbar { position: relative; height: 7px; overflow: hidden; border-radius: 4px; background: var(--tl-surface-sunken); }
.fx-hbar b { position: absolute; inset: 0; border-radius: inherit; background: var(--tl-meter-gradient);
  clip-path: inset(0 calc((1 - var(--meter-level, 0)) * 100%) 0 0 round 4px); transition: clip-path 70ms linear; }
.fx-hbar.is-clipping { box-shadow: 0 0 5px var(--tl-meter-clip); }
.fx-hbar.is-clipping b { background: var(--tl-meter-clip); }
.fx-hbar.is-clipping + output { color: var(--tl-meter-clip); }
.fx-output-strip .fx-endpoint-meters { margin-top: 4px; }
.fx-endpoint-actions .fx-lane-enable[aria-pressed="true"] { border-color: color-mix(in srgb, var(--tl-danger) 50%, transparent); background: var(--tl-danger-tint); color: var(--tl-danger); }

/* Connector: a wire with the insert button on it (ChainConnector in the mock-up). */
.fx-slot { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 26px; }
.fx-wire { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--tl-accent-border); }
/* IN → first slot (and last slot → OUT): one continuous wire from the panel edge, across the column gap and the
   chain's 12px left padding (first wire). Not on a routed B lane, which starts at the junction instead. */
.fx-endpoints:first-child .fx-endpoint::after, .fx-endpoints:last-child .fx-endpoint::before { content: ""; position: absolute; top: 50%; width: var(--rack-gap);
  height: 1px; background: var(--tl-accent-border); }
/* Offsets are from the padding box: step over the 1px border so the stub meets the lane wire. */
.fx-endpoints:first-child .fx-endpoint::after { left: calc(100% + 1px); }
.fx-endpoints:last-child .fx-endpoint::before { right: calc(100% + 1px); }
.fx-chain:not(.is-routed) > .fx-slot:first-child > .fx-wire { left: -12px; }
.fx-add { position: relative; display: grid; place-items: center; width: 25px; height: 25px; min-height: 0; padding: 0; border: 1px solid var(--tl-accent-border);
  border-radius: 50%; color: var(--tl-accent); background: var(--tl-accent-tint); box-shadow: 0 0 10px color-mix(in srgb, var(--tl-accent) 12%, transparent);
  cursor: pointer; transition: background .18s, color .18s, border-color .18s, transform .18s, box-shadow .18s; }
.fx-add:hover { color: var(--tl-on-accent); border-color: var(--tl-accent); background: var(--tl-accent); box-shadow: 0 0 14px color-mix(in srgb, var(--tl-accent) 35%, transparent); transform: scale(1.08); }
.fx-add:focus-visible { outline: none; box-shadow: var(--tl-focus-ring); }
/* Last slot → OUT: the wire fills the rest of the lane, then crosses the chain's right padding and the column gap. */
.fx-output-link { position: relative; flex: 1 0 30px; height: 26px; }
.fx-output-link > .fx-wire { right: -12px; }

/* Effect modules (tl-module host). */
.fx-card { --halo: 0; flex: 0 0 220px; width: 220px; height: 262px; box-sizing: border-box; }
.fx-card.is-selected { outline: 2px solid var(--tl-accent); outline-offset: 3px; }
.fx-card.is-dragging { opacity: .45; }
.fx-drop-target { outline: 2px dashed var(--tl-accent); outline-offset: 4px; }
.fx-photo { position: relative; isolation: isolate; display: grid; flex: 1; min-height: 0; margin: 10px 10px 0; padding: 10px 14px; border: 1px solid var(--tl-border-subtle);
  border-radius: var(--tl-radius-md); background: radial-gradient(circle at 50% 35%, var(--tl-surface-4), var(--tl-surface-sunken) 75%); cursor: grab; touch-action: none; }
.fx-photo:last-child { margin-bottom: 10px; }
/* An active (not bypassed) module frames its photo in the accent colour. */
.fx-card[active] .fx-photo { border: 1px solid var(--tl-accent); box-shadow: inset 0 0 0 2px var(--tl-border), 0 0 12px rgb(199 246 91 / .08); }
.fx-card[active] .fx-photo:focus-visible { box-shadow: inset 0 0 0 2px var(--tl-border), var(--tl-focus-ring); }
.fx-photo:focus-visible { outline: none; box-shadow: var(--tl-focus-ring); }
.fx-photo img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; border-radius: var(--tl-radius-sm); }
/* Level halo: fixed shadows + opacity avoid fragile computed colour arithmetic. */
.fx-photo::after { content: ""; position: absolute; inset: -1px; border: 2px solid currentColor; border-radius: inherit; color: var(--halo-color, var(--tl-success));
  box-shadow: 0 0 9px 2px currentColor, 0 0 20px currentColor, inset 0 0 10px currentColor; opacity: var(--halo); pointer-events: none; transition: opacity 60ms linear; }
.fx-capture-selector { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; gap: 4px; padding: 8px 10px 10px; }
.fx-capture-selector > button { display: grid; place-items: center; height: 28px; min-height: 0; padding: 0; border: 1px solid var(--tl-border); border-radius: var(--tl-radius-sm);
  color: var(--tl-text-2); background: var(--tl-surface-3); font-size: 16px; line-height: 1; cursor: pointer; }
.fx-capture-selector > button:hover:not(:disabled) { border-color: var(--tl-border-hover); color: var(--tl-text); }
.fx-capture-selector > button:focus-visible { outline: none; box-shadow: var(--tl-focus-ring); }
.fx-capture-selector :disabled { opacity: .4; cursor: default; }

/* Per-plugin input/output meters inside the photo frame. */
.fx-meter-fill { position: absolute; inset: 0; background: repeating-linear-gradient(to top, transparent 0 4px, var(--tl-surface-sunken) 4px 6px),
  linear-gradient(to top, var(--tl-meter-ok) 0 77%, var(--tl-meter-warn) 77% 92%, var(--tl-meter-clip) 92%);
  clip-path: inset(calc((1 - var(--meter-level, 0)) * 100%) 0 0); transition: clip-path 70ms linear; }
.fx-thin-meter { position: relative; display: block; width: 4px; min-width: 4px; overflow: hidden; border-radius: 2px; background: var(--tl-surface-sunken); pointer-events: none; }
.fx-thin-meter.is-clipping { background: var(--tl-meter-clip); box-shadow: 0 0 5px var(--tl-meter-clip); }
.fx-thin-meter.is-clipping .fx-meter-fill { background: var(--tl-meter-clip); clip-path: none; }
.fx-card-input-meter, .fx-card-output-meter { position: absolute; top: 10px; bottom: 10px; z-index: 1; }
.fx-card-input-meter { left: 4px; }
.fx-card-output-meter { right: 4px; }

/* A → B junction: route buttons, cable and label. */
.fx-route-action { position: absolute; top: 34px; left: 10px; display: grid; place-items: center; width: 24px; height: 22px; min-height: 0; padding: 0;
  border: 1px solid var(--tl-border-strong); border-radius: var(--tl-radius-sm); color: var(--tl-accent); background: var(--tl-surface-3);
  opacity: 0; pointer-events: none; cursor: pointer; transition: opacity .15s; }
.fx-route-action:hover { border-color: var(--tl-accent-border); background: var(--tl-accent-tint); }
.fx-rack:not(.has-chain-b) .fx-route-action, .fx-route-action[hidden] { display: none; }
.fx-slot.route-visible > .fx-route-action, .fx-slot:hover > .fx-route-action, .fx-slot:focus-within > .fx-route-action { opacity: 1; pointer-events: auto; }
@media (hover: none) { .fx-route-action { opacity: 1; pointer-events: auto; } }
.fx-route-gutter { position: relative; height: 40px; }
.fx-route-cable { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.fx-route-cable path { fill: none; stroke: var(--tl-accent); stroke-width: 2; stroke-linecap: round; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--tl-accent) 40%, transparent)); }
.fx-route-cable path.is-preview { stroke: var(--tl-text-muted); stroke-dasharray: 5 5; filter: none; }
.fx-route-label { position: absolute; top: 5px; z-index: 1; max-width: 280px; height: 26px; min-height: 0; padding: 0 9px; overflow: hidden;
  border: 1px solid var(--tl-accent-border); border-radius: var(--tl-radius-sm); color: var(--tl-accent); background: var(--tl-accent-tint);
  font: 500 var(--tl-fs-2xs) var(--tl-font-mono); white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.fx-routing-dialog { max-width: 420px; }

/* Plugin editor dialog (tl-modal): header, IN | plugin | OUT. Only the plugin scrolls. */
.fx-editor.tl-modal { display: none; width: min(1080px, calc(100vw - 32px)); height: min(860px, calc(100dvh - 32px)); max-height: none; overflow: hidden; }
.fx-editor.tl-modal[open] { display: flex; flex-direction: column; }
.fx-editor.tl-modal.is-compact { width: fit-content; min-width: min(560px, calc(100vw - 32px)); max-width: min(1080px, calc(100vw - 32px)); height: fit-content; max-height: min(860px, calc(100dvh - 32px)); }
.fx-editor.is-compact .fx-editor-mount { display: flex; }
.fx-editor.is-compact .fx-editor-mount > * { margin: auto; }
.fx-editor-bar { flex: none; align-items: center; gap: var(--tl-space-3); padding: 16px 24px 14px; }
.fx-editor-titles { flex: 1; min-width: 0; }
.fx-editor-photo { flex: none; align-self: center; width: 168px; height: 126px; object-fit: contain; background: var(--tl-surface-0); border: 1px solid var(--tl-border-strong); border-radius: var(--tl-radius-md); }
.fx-editor-photo[hidden] { display: none; }
.fx-editor-titles .tl-modal-title { overflow: hidden; font-size: var(--tl-fs-xl); white-space: nowrap; text-overflow: ellipsis; }
.fx-editor .fx-editor-subtitle { margin-top: 6px; overflow: hidden; color: var(--tl-text-muted); font-size: var(--tl-fs-xs); white-space: nowrap; text-overflow: ellipsis; }
.fx-editor-actions { display: flex; align-items: flex-start; gap: var(--tl-space-2); }
.fx-editor-titles > .fx-editor-state { display: inline-flex; margin-top: 8px; }
.fx-editor-close, .fx-editor-revert { border: 1px solid var(--tl-border-strong); border-radius: var(--tl-radius-md); }
.fx-editor-state { padding: 6px 11px; border: 1px solid color-mix(in srgb, var(--tl-warning) 45%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--tl-warning) 10%, transparent); color: var(--tl-warning); font-size: var(--tl-fs-xs); font-weight: 600; }
.fx-editor-state[hidden] { display: none; }
/* Muted lane notice, between the bar and the GUI. */
.fx-editor-muted { display: flex; flex: none; align-items: center; gap: 10px; margin: 12px 24px 0; padding: 8px 8px 8px 12px; border: 1px solid color-mix(in srgb, var(--tl-danger) 45%, transparent);
  border-radius: var(--tl-radius-sm); color: var(--tl-danger); background: var(--tl-danger-tint); font-size: var(--tl-fs-xs); }
.fx-editor-muted > span { flex: 1; min-width: 0; }
.fx-editor-muted > tl-button { flex: none; }
.fx-editor-muted[hidden] { display: none; }
.fx-editor-tabs { flex: none; display: flex; gap: 8px; padding: 0 24px; overflow-x: auto; border-bottom: 1px solid var(--tl-border); scrollbar-width: none; }
.fx-editor-tabs[hidden] { display: none; }
.fx-editor-tab { position: relative; flex: none; min-height: 0; padding: 18px 14px 16px; color: var(--tl-text-muted); background: none; border: 0; border-radius: 0;
  font: 600 var(--tl-fs-control) var(--tl-font-ui); white-space: nowrap; cursor: pointer; }
.fx-editor-tab:hover { color: var(--tl-text); background: none; }
.fx-editor-tab:focus-visible { outline: 2px solid var(--tl-accent); outline-offset: -2px; }
.fx-editor-tab[aria-selected="true"] { color: var(--tl-text); }
.fx-editor-tab[aria-selected="true"]::after { content: ""; position: absolute; right: 6px; bottom: -1px; left: 6px; height: 2px; border-radius: 2px; background: var(--tl-accent); }
.fx-editor-body { position: relative; flex: 1; display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; min-height: 0; padding: 0 8px; }
.fx-editor-mount { min-width: 0; min-height: 0; padding: 22px 14px; overflow: auto; color: var(--tl-text-2); font-size: var(--tl-fs-sm); }
.fx-editor-mount > * { max-width: 100%; }
.fx-editor-side { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.fx-plugin-gain-toggle { width: 44px; height: 44px; border: 1px solid var(--tl-border-strong); border-radius: var(--tl-radius-md); background: var(--tl-surface-3); }
.fx-editor-side-label { color: var(--tl-text-muted); font: 500 var(--tl-fs-2xs) var(--tl-font-mono); letter-spacing: .14em; }
.fx-plugin-gain-toggle.is-active + .fx-editor-side-label { color: var(--tl-accent); }
.fx-plugin-gain-panel { position: absolute; top: 50%; left: calc(100% - 6px); z-index: 8; width: 320px; color: var(--tl-text-2); transform: translateY(-50%);
  border: 1px solid var(--tl-border-strong); border-radius: var(--tl-radius-lg); background: var(--tl-surface-3); box-shadow: var(--tl-shadow-modal); font-size: var(--tl-fs-sm); }
.fx-plugin-gain-panel[hidden] { display: none; }
.fx-editor-output .fx-plugin-gain-panel { left: auto; right: calc(100% - 6px); }
.fx-gain-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 16px 12px; border-bottom: 1px solid var(--tl-border); }
.fx-gain-panel-head .tl-eyebrow { margin-bottom: 4px; }
.fx-editor .fx-gain-panel-head h3 { font-size: var(--tl-fs-lg); }
.fx-gain-panel-body { display: grid; gap: 16px; padding: 16px; }
.fx-gain-readout { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: baseline; }
.fx-gain-readout span { color: var(--tl-text-muted); font-size: var(--tl-fs-2xs); letter-spacing: .06em; text-transform: uppercase; }
.fx-gain-readout strong { color: var(--tl-text); font: 600 var(--tl-fs-sm) var(--tl-font-mono); font-variant-numeric: tabular-nums; }
.fx-thin-meter.is-horizontal { grid-column: 1 / -1; width: 100%; height: 6px; border-radius: var(--tl-radius-pill); }
.fx-thin-meter.is-horizontal .fx-meter-fill { background: linear-gradient(to right, var(--tl-meter-ok) 0 77%, var(--tl-meter-warn) 77% 92%, var(--tl-meter-clip) 92%);
  clip-path: inset(0 calc((1 - var(--meter-level, 0)) * 100%) 0 0); }
.fx-gain-control { display: grid; justify-items: center; padding: 4px 0; }
.fx-gain-panel-body > tl-button { justify-self: center; }

/* Insert / replace library (tl-modal wide, neutral surfaces with sage accents as in the mock-up). */
/* Fixed height whatever the category: header, intro and filter stay put, only the catalog scrolls. */
.fx-menu.tl-modal { height: min(860px, calc(100dvh - 32px)); width: min(920px, calc(100vw - 32px)); border-color: var(--tl-border-strong); box-shadow: 0 35px 90px rgba(0, 0, 0, .68); }
.fx-menu .tl-modal-header { background: var(--tl-surface-4); border-bottom-color: var(--tl-border); }
.fx-menu.tl-modal[open] { display: flex; flex-direction: column; overflow: hidden; }
.fx-menu .tl-modal-header { flex: none; }
.fx-menu .tl-modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 0; }
.fx-menu .tl-modal-body > :not(.fx-menu-catalog) { flex: none; }
.fx-menu-intro { display: flex; align-items: center; justify-content: space-between; gap: var(--tl-space-4); min-height: 66px; padding: 12px 24px; border-bottom: 1px solid var(--tl-border);
  background: var(--tl-surface-2); }
.fx-menu-intro > div { display: flex; flex-direction: column; gap: 4px; }
.fx-menu-intro strong { font-size: var(--tl-fs-control); }
.fx-menu-intro div span { color: var(--tl-text-muted); font-size: var(--tl-fs-xs); }
.fx-menu-count { flex: none; padding: 5px 8px; border-radius: var(--tl-radius-sm); color: var(--tl-accent-muted-strong); background: var(--tl-accent-muted-tint);
  font: 600 var(--tl-fs-2xs) var(--tl-font-mono); text-transform: uppercase; }
.tl-modal .fx-menu-status { margin: 0; padding: 0 24px; color: var(--tl-text-2); font-size: var(--tl-fs-xs); overflow-wrap: anywhere; }
.fx-menu-status:not(:empty) { padding-top: 10px; }
.fx-menu-side { display: flex; align-items: center; gap: var(--tl-space-3); padding: 12px 24px 0; }
.fx-menu-side tl-select { width: 220px; }
.fx-menu-filter { padding: 12px 24px 0; }
.fx-menu-filter tl-segmented { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.fx-menu-catalog { flex: 1; min-height: 0; overflow-y: auto; align-content: start; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px 30px; padding: 22px 24px 28px; }
.fx-menu-category { min-width: 0; }
.fx-menu-category:nth-child(n+3) { grid-column: 1 / -1; padding-top: 24px; border-top: 1px solid var(--tl-border); }
.fx-menu-category > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fx-menu-category > header > div { display: flex; align-items: center; gap: 8px; color: var(--tl-accent-muted); }
.fx-menu-category h3 { margin: 0; color: var(--tl-text); font-size: var(--tl-fs-md); text-transform: capitalize; }
.fx-menu-category > header > .fx-menu-count { min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; border-radius: var(--tl-radius-pill); color: var(--tl-accent-muted); }
.fx-menu-catalog.is-filtered { grid-template-columns: minmax(0, 1fr); }
.fx-menu-catalog.is-filtered .fx-menu-category { grid-column: auto; padding-top: 0; border-top: 0; }
.fx-menu-catalog.is-filtered .fx-menu-category > header { display: none; }
.fx-menu-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fx-menu-entry { display: flex; flex-direction: column; min-width: 0; padding: 8px; border: 1px solid var(--tl-border); border-radius: var(--tl-radius-lg); color: var(--tl-text-1);
  background: var(--tl-surface-3); transition: border-color .18s, background-color .18s, box-shadow .18s; }
.fx-menu-entry:hover, .fx-menu-entry:focus-within { border-color: var(--tl-border-hover); background: var(--tl-surface-4); box-shadow: 0 9px 24px rgba(0, 0, 0, .28); }
.fx-menu-item { display: flex; flex-direction: column; min-width: 0; }
.fx-menu-item img { width: 100%; height: 92px; object-fit: contain; border-radius: var(--tl-radius-sm); background: var(--tl-surface-sunken); }
.fx-menu-item strong { min-height: 30px; margin: 9px 2px 0; font-size: var(--tl-fs-sm); line-height: 1.35; }
.fx-menu-insert { display: flex; align-items: center; justify-content: center; gap: 5px; width: 100%; height: 30px; min-height: 0; margin-top: auto; /* Insert sits at the bottom of the card, under the URI */ padding: 0; border: 1px solid var(--tl-border-strong);
  border-radius: var(--tl-radius-sm); color: var(--tl-text-2); background: var(--tl-surface-2); font: inherit; font-size: var(--tl-fs-xs); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  transition: color .18s, border-color .18s, background-color .18s; }
.fx-menu-insert:hover:not(:disabled) { color: var(--tl-on-accent); border-color: var(--tl-accent); background: var(--tl-accent); }
.fx-menu-insert:focus-visible, .fx-copy-uri:focus-visible { outline: none; box-shadow: var(--tl-focus-ring); }
.fx-copy-uri { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; height: 25px; min-height: 0; margin: 2px 0 8px; padding: 0 4px; border: 0; color: var(--tl-text-muted);
  background: none; font: 500 var(--tl-fs-2xs) var(--tl-font-mono); cursor: copy; }
.fx-copy-uri span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fx-copy-uri tl-icon { flex: none; color: var(--tl-text-faint); }
.fx-copy-uri:hover { color: var(--tl-text-2); }
.fx-copy-uri:hover tl-icon { color: var(--tl-accent); }
.fx-menu button:disabled { opacity: .5; cursor: progress; }

@media (prefers-reduced-motion: reduce) {
  .fx-photo::after, .fx-meter-fill, .fx-add, .fx-menu-entry, .fx-menu-insert { transition: none; }
  .fx-add:hover { transform: none; }
}
@media (max-width: 900px) {
  .fx-rack { --rack-gap: 4px; grid-template-columns: 150px minmax(0, 1fr) 150px; padding: 0 6px; }
  .fx-endpoint { --pad: 7px; }
  .rack-dock { padding-left: 10px; padding-right: 10px; }
}
/* Sticky would cover the page on phones, where the rack is most of the viewport. */
@media (max-width: 720px) { .fx-rack { position: relative; top: auto; } }
@media (max-width: 560px) {
  .fx-menu-catalog { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .fx-menu-category:nth-child(n+2) { grid-column: auto; padding-top: 16px; border-top: 1px solid var(--tl-border); }
  .fx-menu-intro { padding: 12px 16px; }
  .fx-menu-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .fx-editor-bar { padding: 14px 16px 12px; }
  .fx-editor-muted { margin: 10px 16px 0; }
  .fx-editor-photo { width: 104px; height: 78px; }
  .fx-editor-tabs { padding: 0 8px; gap: 0; }
  .fx-editor-tab { padding: 14px 10px 12px; }
  /* IN and OUT share a row above the plugin, which keeps the full width. */
  .fx-editor-body { grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr); padding: 0; }
  .fx-editor-side { flex-direction: row; justify-content: flex-start; padding: 10px 16px 0; }
  .fx-editor-input { grid-area: 1 / 1; }
  .fx-editor-output { grid-area: 1 / 2; flex-direction: row-reverse; }
  .fx-editor-mount { grid-area: 2 / 1 / 3 / 3; padding: 10px 6px; }
  .fx-plugin-gain-toggle { width: 36px; height: 36px; }
  .fx-plugin-gain-panel, .fx-editor-output .fx-plugin-gain-panel { top: calc(100% + 6px); left: 16px; right: auto; width: min(320px, calc(100vw - 64px)); transform: none; }
  .fx-editor-output .fx-plugin-gain-panel { left: auto; right: 16px; }
}
@media (max-width: 420px) {
  .fx-rack { grid-template-columns: 124px minmax(0, 1fr) 124px; }
  .fx-endpoint { --pad: 5px; }
  .fx-endpoint-head { padding: 0 8px; }
  .fx-endpoint-actions { grid-template-columns: 40px minmax(0, 1fr); gap: 4px; }
  .fx-endpoint-actions .fx-lane-enable { padding: 0 6px; }
  .fx-endpoint-actions .fx-lane-enable::part(icon) { display: none; }
  .fx-endpoint-actions .fx-endpoint-reset { padding: 0; }
}

/* The catalog thumbnail and title also support double-click insertion/replacement. */
.fx-menu-item { cursor: pointer; }

/* Keep calibration legible and full-height instead of letting flex shrink it. */
.fx-input-strip { gap: 4px; }
.fx-input-gain-row { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 82px; flex: none; }
.fx-input-gain-row .fx-gain { margin: 0; }
.fx-input-gain-row .fx-endpoint-reset { margin: 0; padding-inline: 5px; font-size: 10px; }
.fx-input-auto { flex: none; box-sizing: border-box; min-height: 30px; width: 100%; margin-top: auto; font-size: 11px; }
