#inspector:has(#catalog:not([hidden])) {
  inset:calc(var(--top) + 62px) var(--right) auto auto;
  width:min(1040px,calc(100% - var(--right) - var(--left)));
  height:min(720px,calc(100% - var(--top) - var(--bottom) - 118px));
  max-height:none; padding:0; overflow:hidden; z-index:5;
}
#catalog { display:grid; grid-template-rows:auto minmax(0,1fr) auto; height:100%; min-width:0; }
.catalog-head,.catalog-footer,.catalog-selection { display:flex; align-items:center; gap:12px; min-width:0; }
.catalog-head { padding:11px 14px 11px 20px; border-bottom:1px solid var(--line); }
#catalog h2 { font-size:18px; white-space:nowrap; }
.catalog-tabs { display:flex; margin-left:14px; background:var(--hud-inset); padding:3px; border:1px solid var(--line); border-radius:var(--hud-radius); }
.catalog-tabs button { min-height:34px; padding:0 14px; font-size:12px; color:var(--muted); border:0; }
.catalog-tabs button[aria-selected=true] { color:var(--ink); background-color:var(--hud-pressed); }
.catalog-close { margin-left:auto; width:40px; min-height:40px; border:0; color:var(--muted); font-size:23px; }
#catalog-wiring { display:grid; grid-template-columns:172px minmax(0,1fr); min-height:0; }
.catalog-palette { min-width:0; padding:12px 8px; border-right:1px solid var(--line); overflow:auto; }
.catalog-palette summary { display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:34px; padding:0 7px; font-size:12px; font-weight:600; list-style:none; }
.catalog-palette summary::-webkit-details-marker { display:none; }
.catalog-palette summary::after { content:'+'; font:17px var(--mono); color:var(--muted); }
.catalog-palette[open] summary::after { content:'−'; }
.catalog-category { display:none; }
.catalog-add { display:grid; margin-top:6px; }
.catalog-add fieldset { min-width:0; margin:0 0 9px; padding:0; border:0; display:grid; }
.catalog-add legend { padding:0 7px; color:var(--muted); font-size:12px; font-weight:600; }
.catalog-add button { display:flex; align-items:center; gap:8px; min-height:44px; border:0; padding:5px 7px; text-align:start; font-size:12px; }
#catalog .device-icon { width:19px; height:19px; flex:none; color:#b7bcb0; fill:none; stroke:currentColor; stroke-width:1.35; stroke-linecap:round; stroke-linejoin:round; }
.catalog-add button[data-installed=true] { opacity:.45; }
.catalog-add button[data-installed=true]::after { content:'✓'; margin-left:auto; font-size:11px; }
.catalog-workspace { display:grid; grid-template-rows:minmax(0,1fr) auto; min-height:0; min-width:0; }
.catalog-viewport { overflow:auto; overscroll-behavior:contain; min-width:0; scrollbar-width:thin;
  background:#1c201f radial-gradient(circle,#8e9b841f .8px,transparent 1px) 0 0/14px 14px; }
.catalog-board { position:relative; isolation:isolate; display:grid; align-items:center; align-content:center;
  grid-template-columns:repeat(var(--columns),minmax(0,1fr)); row-gap:22px; column-gap:clamp(17px,3vw,48px);
  min-height:100%; padding:30px clamp(14px,2.1vw,28px); }
.catalog-wires { position:absolute; inset:0; width:100%; height:100%; overflow:visible; pointer-events:none; }
.catalog-wires path { fill:none; stroke:#8c9e8f; stroke-width:1.6; stroke-linejoin:round; }
.catalog-wires .selected { stroke:var(--accent); stroke-width:2; }
.catalog-wires .preview { stroke-dasharray:4 4; }
.catalog-node { position:relative; justify-self:center; grid-column:var(--col); width:100%; max-width:210px; min-width:0;
  background:#2a2e2a; border:1px solid #555d53; border-radius:6px; box-shadow:0 3px 7px #0003; }
.catalog-node[data-selected=true] { border-color:#c3ad83; background:#30332d; }
.catalog-node button { display:flex; align-items:center; position:relative; width:100%; border:0; text-align:left; font-size:12px; }
.catalog-node [data-node-id] { min-height:44px; padding:8px 10px; gap:7px; font-weight:570; line-height:1.3; overflow-wrap:anywhere; }
.catalog-node [data-port] { min-height:38px; padding:4px 14px; border-radius:0; border-top:1px solid #ffffff13; color:var(--ink); }
.catalog-node [data-role=socket] { justify-content:flex-end; text-align:end; }
.catalog-node [data-port][aria-pressed=true] { color:#ffe0a9; background:#b3a17e12; }
.port-label { display:grid; gap:2px; min-width:0; line-height:1.15; overflow-wrap:anywhere; }
.port-type { color:var(--muted); font-size:11px; }
.port-marker { position:absolute; left:-8px; top:50%; transform:translateY(-50%); width:16px; height:16px;
  display:grid; place-items:center; border:1px solid #8a8d82; border-radius:50%; background:var(--surface-inset); color:var(--ink); }
.port-marker svg { width:12px; height:12px; fill:none; stroke:currentColor; stroke-width:1.45; stroke-linecap:round; stroke-linejoin:round; }
[data-role=socket] .port-marker { left:auto; right:-8px; border-radius:4px; }
[data-connected=true] .port-marker { background:#aabbab; color:#242824; border-color:#2a302c; box-shadow:0 0 0 1px #aabbab; }
[aria-pressed=true] > .port-marker { background:var(--accent); color:#252520; box-shadow:0 0 0 1px var(--accent); }
.port-marker .port-lock, [data-connect-target=occupied] .port-icon { display:none; }
[data-connect-target=occupied] .port-marker .port-lock { display:block; }
[data-connect-target=occupied] .port-marker { background:var(--surface-inset); color:var(--muted); border-color:var(--muted); box-shadow:none; }
.catalog-node [data-connect-target=available] { background:#d6bc8c24; color:#ffe0a9; }
[data-connect-target=available] .port-type { color:inherit; }
[data-connect-target=available] .port-marker { background:var(--surface-inset); border-color:var(--accent); color:var(--accent);
  box-shadow:0 0 0 1px var(--accent); }
[data-connect-target=incompatible] .port-label { opacity:.68; }
.catalog-selection { min-height:52px; padding:4px 14px; border-top:1px solid var(--line); }
.catalog-context { flex:1; margin:0; color:#c5c8be; font-size:12px; line-height:1.45; overflow-wrap:anywhere; }
.catalog-selection button,.catalog-footer button { min-height:36px; padding:5px 11px; font-size:12px; white-space:nowrap; }
.catalog-selection button { color:#ddd5c5; }
.catalog-power:not([hidden]) { display:flex; flex-wrap:wrap; gap:6px; padding:0 14px 9px; }
.catalog-power button { display:flex; align-items:center; gap:7px; min-height:36px; padding:5px 9px; font-size:12px; }
.catalog-power button span { color:#a39a88; }
.catalog-power button[data-powered=true] span { color:#ecad61; }
.catalog-footer { min-height:57px; padding:8px 14px; border-top:1px solid var(--line); }
.catalog-notice { flex:1; color:var(--accent); font-size:12px; line-height:1.45; overflow-wrap:anywhere; }
.catalog-footer .catalog-apply { border-color:#b39d77; background:#d6bc8c; color:#252520; font-weight:650; }
.catalog-footer .catalog-apply:hover:enabled { background:#ead1a3; }
#catalog-presets { min-height:0; overflow:auto; padding:20px clamp(14px,3vw,40px); }
#catalog-presets > p { margin:0 0 16px; color:var(--muted); font-size:12px; line-height:1.5; }
.catalog-presets { display:grid; gap:10px; grid-template-columns:repeat(3,minmax(0,1fr)); }
.catalog-presets button { position:relative; display:grid; align-content:start; gap:11px; padding:18px 15px; text-align:start; line-height:1.5; background:#292d29; }
.catalog-presets strong { font-size:15px; font-weight:550; }
.catalog-presets span { font-size:12px; color:var(--muted); }
.catalog-presets [aria-pressed=true] { border-color:#b3a17e; }
.catalog-presets [aria-pressed=true]::after { content:'✓'; position:absolute; top:15px; right:14px; color:var(--accent); }
.catalog-personal { margin-top:24px; padding-top:18px; border-top:1px solid var(--line); }
.catalog-personal h3 { margin:0 0 10px; font-size:14px; font-weight:550; }
.catalog-save,.catalog-saved li { display:flex; align-items:center; gap:8px; }
.catalog-save input { min-width:0; width:min(230px,55%); min-height:44px; padding:6px 10px; border:1px solid var(--line); border-radius:4px; background:#272929; color:var(--ink); font:inherit; font-size:13px; }
.catalog-personal button { min-height:44px; padding:6px 12px; font-size:12px; }
.catalog-saved { list-style:none; padding:0; margin:12px 0 0; }
.catalog-saved li { border-top:1px solid var(--line); }
.catalog-saved button { border:0; text-align:start; }
.catalog-saved [data-saved-preset] { flex:1; min-width:0; overflow-wrap:anywhere; }
.catalog-saved [data-delete-preset] { color:var(--muted); }

@media(max-width:840px) and (min-height:481px) {
  #inspector:has(#catalog:not([hidden])) { top:calc(var(--top) + 96px); height:calc(100% - var(--top) - var(--bottom) - 150px); }
  #catalog-wiring { grid-template-columns:152px minmax(0,1fr); }
}
@media(max-width:700px) {
  #catalog-wiring { display:flex; flex-direction:column; }
  .catalog-palette { flex:none; padding:0 9px; border-right:0; border-bottom:1px solid var(--line); max-height:60%; overflow:auto; }
  .catalog-palette summary { min-height:44px; padding:0 5px; }
  .catalog-category { display:block; width:100%; min-height:40px; font:inherit; }
  .catalog-add { max-height:22dvh; overflow-y:auto; overscroll-behavior:contain; margin:4px 0; }
  .catalog-add fieldset[data-active=false], .catalog-add legend { display:none; }
  .catalog-add fieldset { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .catalog-add button { font-size:12px; }
  .catalog-workspace { flex:1; }
  .catalog-head { gap:5px; padding:5px 6px 5px 12px; }
  .catalog-tabs { margin-left:6px; padding:0; }
  .catalog-close,.catalog-tabs button { min-height:44px; }
  .catalog-close { width:44px; }
  .catalog-tabs button { padding:0 11px; }
  .catalog-board { display:flex; flex-direction:column; align-items:stretch; justify-content:safe center; gap:14px; padding:17px 15px 17px 33px; }
  .catalog-node { flex:none; width:auto; max-width:none; margin-left:calc((var(--col) - 1) * 12px); }
  .catalog-node [data-port] { min-height:44px; }
  .catalog-node [data-role=socket] { justify-content:flex-start; text-align:start; }
  [data-role=socket] .port-marker { right:auto; left:-8px; }
  .catalog-selection { min-height:49px; padding:3px 9px; }
  .catalog-footer { padding:5px 7px 5px 10px; gap:6px; }
  .catalog-footer button,.catalog-selection button { min-height:44px; }
  .catalog-presets { grid-template-columns:1fr; }
  .catalog-presets button { gap:4px; padding:12px; }
  .catalog-save input { font-size:16px; }
}
@media(max-height:480px) and (min-width:570px) {
  #inspector:has(#catalog:not([hidden])) { inset:var(--top) var(--right) var(--bottom) auto; height:auto; }
}
.catalog-footer > div { flex:1; min-width:0; }
.catalog-removal { margin:4px 0 0; color:#efb7a9; font-size:12px; overflow-wrap:anywhere; }
