.lgl-root,
.lgl-root * {
  box-sizing: border-box;
}

.lgl-root {
  --lgl-bg: #f4f7fb;
  --lgl-panel: #ffffff;
  --lgl-border: #d6dbe5;
  --lgl-shadow: 0 18px 45px rgba(20, 34, 62, 0.12);
  --lgl-text: #202a36;
  --lgl-text-soft: #607082;
  --lgl-primary: #2254d1;
  --lgl-primary-soft: #edf3ff;
  --lgl-danger: #b73030;
  --lgl-success: #0f8d5b;
  --lgl-warning: #d78c11;
  color: var(--lgl-text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 1.25rem 0;
}

.lgl-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lgl-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(246,249,255,0.96));
  border: 1px solid var(--lgl-border);
  border-radius: 18px;
  box-shadow: var(--lgl-shadow);
  padding: 0.85rem;
}

.lgl-toolbar__group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lgl-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 420px);
  gap: 1rem;
}

.lgl-panel {
  background: var(--lgl-panel);
  border: 1px solid var(--lgl-border);
  border-radius: 22px;
  box-shadow: var(--lgl-shadow);
  overflow: hidden;
}

.lgl-panel--canvas {
  min-width: 0;
}

.lgl-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.15rem 0.75rem;
}

.lgl-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.lgl-panel__meta {
  margin: 0.2rem 0 0;
  color: var(--lgl-text-soft);
  font-size: 0.9rem;
}

.lgl-panel__content {
  padding: 0 1.15rem 1.15rem;
}

.lgl-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lgl-canvas-wrap {
  position: relative;
  margin: 0 1rem 1rem;
  min-height: 660px;
  max-height: 78vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--lgl-border);
  background-color: #f8fbff;
  background-image:
    linear-gradient(rgba(50, 81, 145, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 81, 145, 0.07) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(34, 84, 209, 0.12), transparent 38%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
}

.lgl-canvas {
  position: relative;
  z-index: 2;
  width: 1800px;
  height: 1200px;
  pointer-events: none;
}

.lgl-wire-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 1800px;
  height: 1200px;
  overflow: visible;
  pointer-events: auto;
}

.lgl-wire {
  fill: none;
  stroke: #48566a;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  filter: drop-shadow(0 2px 1px rgba(12, 19, 33, 0.15));
}

.lgl-wire.is-high {
  stroke: var(--lgl-success);
}

.lgl-wire.is-low {
  stroke: #55657b;
}

.lgl-wire.is-unknown {
  stroke: var(--lgl-warning);
  stroke-dasharray: 10 7;
}

.lgl-wire.is-selected {
  stroke-width: 6;
}

.lgl-wire--pending {
  opacity: 0.9;
}

.lgl-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.lgl-status__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: #eef3ff;
  color: #25407a;
  font-size: 0.8rem;
  font-weight: 600;
}

.lgl-button {
  appearance: none;
  border: 1px solid rgba(56, 78, 120, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #edf2fb);
  color: var(--lgl-text);
  box-shadow: 0 6px 14px rgba(13, 23, 38, 0.08);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.58rem 0.92rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.lgl-button:hover,
.lgl-button:focus-visible {
  border-color: rgba(34, 84, 209, 0.42);
  box-shadow: 0 10px 18px rgba(13, 23, 38, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.lgl-button--primary {
  background: linear-gradient(180deg, #2d62e8, #1f4fbf);
  border-color: #1f4fbf;
  color: #ffffff;
}

.lgl-node {
  position: absolute;
  z-index: 3;
  width: 178px;
  min-height: 124px;
  border-radius: 20px;
  border: 1px solid rgba(40, 57, 85, 0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(232,238,247,0.98));
  box-shadow: 0 14px 25px rgba(16, 28, 45, 0.16);
  cursor: grab;
  overflow: visible;
  user-select: none;
  pointer-events: auto;
}

.lgl-node.is-selected {
  border-color: rgba(34, 84, 209, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 84, 209, 0.12), 0 20px 34px rgba(16, 28, 45, 0.22);
}

.lgl-node:active {
  cursor: grabbing;
}

.lgl-node--INPUT,
.lgl-node--OUTPUT {
  width: 154px;
}

.lgl-node__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem 0.45rem;
  border-radius: 19px 19px 0 0;
  background: linear-gradient(180deg, rgba(27, 38, 56, 0.96), rgba(39, 53, 76, 0.96));
  color: #f3f7ff;
}

.lgl-node__type {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.lgl-node__signal {
  min-width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  background: rgba(255,255,255,0.12);
}

.lgl-node__signal.is-high,
.lgl-mini-toggle.is-high,
.lgl-output-lamp.is-high,
.lgl-port--out.is-high {
  color: #ffffff;
  background: radial-gradient(circle at 30% 30%, #4dffaf, #118557 70%);
  box-shadow: 0 0 14px rgba(17, 133, 87, 0.45);
}

.lgl-node__signal.is-low,
.lgl-mini-toggle.is-low,
.lgl-output-lamp.is-low,
.lgl-port--out.is-low {
  color: #f2f4f8;
  background: radial-gradient(circle at 30% 30%, #8e9cb0, #56667a 72%);
}

.lgl-node__signal.is-unknown,
.lgl-mini-toggle.is-unknown,
.lgl-output-lamp.is-unknown,
.lgl-port--out.is-unknown {
  color: #fffaf1;
  background: radial-gradient(circle at 30% 30%, #ffd978, #d38914 72%);
  box-shadow: 0 0 12px rgba(211, 137, 20, 0.38);
}

.lgl-node__label {
  padding: 0.55rem 0.85rem 0;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--lgl-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lgl-node__body {
  position: relative;
  padding: 0.35rem 1.1rem 0.95rem;
  min-height: 78px;
  border-radius: 0 0 19px 19px;
}

.lgl-node__visual {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 78px;
}

.lgl-node__visual svg {
  width: 118px;
  height: 72px;
  display: block;
}

.lgl-port {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 999px;
  border: 3px solid #2b3441;
  background: radial-gradient(circle at 35% 35%, #fff, #b7c1d1);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lgl-port:hover,
.lgl-port:focus-visible {
  transform: scale(1.12);
  outline: none;
}

.lgl-port--in {
  left: -10px;
}

.lgl-port--out {
  right: -10px;
}

.lgl-port.is-pending {
  box-shadow: 0 0 0 5px rgba(34, 84, 209, 0.18);
}

.lgl-mini-toggle {
  position: absolute;
  right: 0.75rem;
  bottom: 0.55rem;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(17, 28, 46, 0.18);
}

.lgl-output-lamp {
  position: absolute;
  right: 0.85rem;
  bottom: 0.55rem;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
}

.lgl-input,
.lgl-field {
  width: 100%;
}

.lgl-field {
  display: block;
}

.lgl-field__label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--lgl-text-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lgl-input {
  appearance: none;
  border: 1px solid var(--lgl-border);
  border-radius: 14px;
  background: #fbfdff;
  color: var(--lgl-text);
  font: inherit;
  padding: 0.75rem 0.9rem;
}

.lgl-input:focus {
  outline: none;
  border-color: rgba(34, 84, 209, 0.46);
  box-shadow: 0 0 0 4px rgba(34, 84, 209, 0.12);
}

.lgl-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.lgl-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.58rem;
  border-radius: 999px;
  background: var(--lgl-primary-soft);
  color: #204ba5;
  font-size: 0.8rem;
  font-weight: 700;
}

.lgl-inspector__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.lgl-help,
.lgl-help-list,
.lgl-diagnostics,
.lgl-saved-item__meta {
  color: var(--lgl-text-soft);
  font-size: 0.93rem;
}

.lgl-help {
  margin: 0;
}

.lgl-help-list,
.lgl-diagnostics {
  margin: 0;
  padding-left: 1.1rem;
}

.lgl-diagnostics {
  color: var(--lgl-danger);
}

.lgl-truth-table-wrap {
  min-height: 150px;
}

.lgl-truth-table-scroll {
  overflow: auto;
  border: 1px solid var(--lgl-border);
  border-radius: 16px;
  background: #fcfdff;
}

.lgl-truth-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 280px;
}

.lgl-truth-table th,
.lgl-truth-table td {
  border-bottom: 1px solid rgba(71, 88, 119, 0.12);
  padding: 0.65rem 0.7rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lgl-truth-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f1f6ff, #e4ecfb);
  color: #224285;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lgl-truth-table tbody tr:nth-child(even) {
  background: rgba(103, 131, 177, 0.05);
}

.lgl-saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.95rem;
}

.lgl-saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.85rem;
  border-radius: 16px;
  border: 1px solid var(--lgl-border);
  background: #f9fbff;
}

.lgl-saved-item.is-active {
  border-color: rgba(34, 84, 209, 0.36);
  background: #eef4ff;
}

.is-hidden {
  display: none;
}

@media (max-width: 1120px) {
  .lgl-workspace {
    grid-template-columns: 1fr;
  }

  .lgl-sidebar {
    order: 2;
  }
}

@media (max-width: 720px) {
  .lgl-toolbar {
    padding: 0.75rem;
  }

  .lgl-panel__header {
    flex-direction: column;
    align-items: stretch;
  }

  .lgl-canvas-wrap {
    min-height: 520px;
  }
}
