form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
}

input {
  width: 8rem;
  padding: 0.4rem;
  font: inherit;
}

button {
  padding: 0.45rem 0.8rem;
  font: inherit;
  cursor: pointer;
}

#info {
  margin-bottom: 1rem;
  white-space: pre-line;
}

#diagram {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 20rem;
}

#diagram svg {
  display: block;
  width: min(100%, 40rem);
  height: auto;
  overflow: visible;
}

#tooltip {
  position: fixed;
  z-index: 10;
  display: none;
  pointer-events: none;
  padding: 0.45rem 0.6rem;
  border: 1px solid #555;
  border-radius: 0.3rem;
  background: #222;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}

.item-part {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 120ms ease-out;
}

.item-part.is-hovered {
  transform: scale(1.08);
}

.loading-state {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: CanvasText;
  opacity: 0.7;
}

.loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: loading-spin 700ms linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.diagram-wrapper:not(.is-loading) .loading-state {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation-duration: 1.5s;
  }
}
