.editor-views {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 18px;
}
.editor-views [aria-pressed='true'] {
  background: var(--accent);
  color: var(--bg, #171c1a);
}
.logic-toolbar,
.logic-add,
.logic-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.logic-actions .btn {
  min-height: 44px;
}
.logic-toolbar > div:first-child {
  margin-right: auto;
}
.logic-toolbar h2,
.logic-toolbar h3 {
  margin: 0;
}
.logic-toolbar p {
  margin: 5px 0;
  font-size: 14px;
  color: var(--muted);
}
.logic-toolbar label {
  margin: 0;
}
.logic-toolbar select {
  min-width: 85px;
}
.logic-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.logic-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.logic-add {
  margin: 18px 0 10px;
  padding: 14px;
  border: 1px solid #536258;
  border-radius: 10px;
  background: #1e2722;
  align-items: flex-end;
}
.logic-add label {
  flex: 1;
  min-width: 180px;
  margin: 0;
}
.logic-add select {
  width: 100%;
}
.logic-legend {
  display: inline-block;
  margin-left: 16px;
  color: #c2d4ab;
}
#logic-status {
  min-height: 1.5em;
  font-size: 14px;
  color: #d7c2aa;
}
.logic-problems {
  margin: 12px 0;
  color: #efb3a1;
}
.logic-scroll {
  height: 620px;
  max-height: 72vh;
  overflow: auto;
  border: 1px solid #536258;
  border-radius: 12px;
  background: #111b17;
}
.logic-canvas {
  position: relative;
  transform-origin: top left;
  background-image: radial-gradient(#455247 1px, transparent 1px);
  background-size: 16px 16px;
}
.logic-node {
  position: absolute;
  width: 280px;
  border: 1px solid #65725f;
  border-radius: 10px;
  background: #253129;
  box-shadow: 0 6px 18px #0005;
  overflow: hidden;
}
.logic-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #e7b48b66;
}
.logic-node header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #344336;
  cursor: grab;
  touch-action: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.logic-delete {
  background: none;
  border: 0;
  color: #e6d7c4;
  padding: 0 4px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.logic-label {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: #f2eadc;
  font-size: 14px;
  border: 0;
  border-bottom: 1px solid #536258;
  border-radius: 0;
}
.logic-label::placeholder {
  color: #d6d5bc;
  opacity: 1;
}
.logic-ports {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}
.logic-ports > div {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.logic-port {
  background: transparent;
  color: #d5e0c5;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 5px;
  font-size: 12px;
  text-align: left;
  min-height: 29px;
  cursor: pointer;
}
.logic-ports .outputs .logic-port {
  text-align: right;
}
.logic-port.event {
  color: #ebba85;
}
.logic-port.test-event {
  border-color: #936e45;
  cursor: pointer;
}
.logic-port.active {
  color: #fff0a4;
  background: #ddbd4c33;
}
.logic-port.compatible {
  border-color: #97bd83;
  background: #81966522;
}
.logic-port[aria-pressed='true'] {
  background: #dca36d44;
  border-color: #e7b48b;
}
.logic-settings {
  padding: 0 12px 10px;
  font-size: 12px;
}
.logic-settings label {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin: 7px 0;
  font-size: 11px;
  letter-spacing: 0.03em;
}
.logic-settings input[type='number'] {
  width: 90px;
  padding: 4px 7px;
}
.logic-settings input[type='text'] {
  min-width: 0;
  width: 65%;
  padding: 4px 7px;
}
.logic-workbench {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.logic-workbench .logic-scroll {
  min-width: 0;
}
.logic-workbench .logic-preview {
  margin: 0;
  padding: 14px;
}
@media (min-width: 1100px) {
  .logic-workbench {
    grid-template-columns: minmax(0, 1fr) 310px;
    align-items: start;
  }
  .logic-workbench .logic-preview {
    position: sticky;
    top: 16px;
  }
  .logic-preview .logic-toolbar h3 {
    width: 100%;
  }
}
.logic-settings input[type='checkbox'] {
  width: 16px;
  accent-color: var(--accent);
}
.logic-settings label:has(select) {
  display: block;
}
.logic-settings select {
  width: 100%;
  font-size: 12px;
  padding: 5px;
}
.logic-settings details {
  margin-top: 6px;
}
.logic-settings summary {
  cursor: pointer;
  color: #c8c9b0;
}
.logic-settings small {
  display: block;
  color: #bec5ac;
  font-size: 11px;
}
.logic-settings textarea {
  font-size: 12px;
  min-height: 54px;
  width: 100%;
}
.logic-coordinates {
  display: flex;
  gap: 10px;
}
.logic-live {
  display: block;
  background: #16251b;
  color: #b9d49c;
  font-size: 11px;
  padding: 5px 10px;
  min-height: 8px;
}
.logic-wires {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.logic-wire-line {
  fill: none;
  stroke: #9bba87;
  stroke-width: 2.5;
  pointer-events: none;
}
.logic-wire-line.event {
  stroke: #d7a276;
  stroke-dasharray: 6 5;
}
.logic-wire.active .logic-wire-line {
  stroke: #eddf87;
  stroke-width: 4;
}
.logic-wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
}
.logic-wire {
  outline: none;
}
.logic-wire:hover .logic-wire-line {
  stroke-width: 4;
}
.logic-wire:focus-visible {
  outline: 2px dotted #f2ddb9;
  outline-offset: 4px;
}
.logic-wire.selected .logic-wire-line {
  stroke: #ffc28d;
  stroke-width: 5;
}
.logic-empty {
  position: absolute;
  left: 40px;
  top: 80px;
  color: #b7bda5;
  line-height: 1.8;
}
.logic-connections,
.logic-legacy {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #435345;
  border-radius: 8px;
  font-size: 13px;
}
.logic-connections summary,
.logic-legacy summary {
  cursor: pointer;
  font-weight: 600;
}
.logic-connections ul {
  padding: 0;
  list-style: none;
}
.logic-connections li {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 3px 0;
}
.logic-preview {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid #536258;
  border-radius: 12px;
}
#logic-preview-board {
  width: 100%;
  max-width: 800px;
  height: auto;
  display: block;
  margin: 12px auto;
}
#logic-preview-board:focus {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
@media (max-width: 700px) {
  .logic-scroll {
    height: 520px;
  }
  .logic-add {
    gap: 8px;
  }
  .logic-add label {
    min-width: 60%;
  }
}
.editor-layout[hidden],
#logic-editor[hidden] {
  display: none;
}

.logic-channel {
  margin: 0.8rem 0;
}
.logic-channel.selected,
.logic-channel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}
.logic-channel p {
  margin-bottom: 0.4rem;
}
.logic-channel small {
  display: block;
  margin-top: 0.3rem;
}
.logic-node.conversion-group {
  box-shadow: 0 0 0 2px #709d8e;
}
.logic-wire.conversion-group .logic-wire-line {
  stroke: #9bbfad;
}
.logic-wire.selected .logic-wire-line {
  stroke: var(--accent);
}
