.mp-latency {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.9rem;
}
.mp-latency input {
  flex: 1;
  min-width: 0;
  max-width: 240px;
}
.mp-latency output {
  min-width: 6ch;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mp-wrap {
  container-type: inline-size;
}
.mp-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.mp-panel {
  min-width: 0;
}
.mp-head {
  margin-bottom: 0.4rem;
  color: var(--muted);
}
.mp-canvas {
  position: relative;
  height: 120px;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
  touch-action: none;
}
.mp-shape {
  --s: 30px;
  position: absolute;
  top: calc((100% - var(--s)) * var(--y));
  left: calc((100% - var(--s)) * var(--x));
  width: var(--s);
  height: var(--s);
  padding: 0;
  border: 0;
  border-radius: 3px;
  cursor: grab;
  touch-action: none;
  transition: background-color 150ms ease-out;
}
.mp-circle {
  border-radius: 50%;
}
.mp-shape.mp-sel {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--fg);
}
.mp-shape.mp-wait {
  outline: 1.5px dashed var(--redline);
  outline-offset: 4px;
}
.mp-shape:active {
  cursor: grabbing;
}
.mp-swatches {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.mp-swatch {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
.mp-pending {
  margin-top: 0.4rem;
  min-height: 2.6em;
  color: var(--muted);
  font-size: 0.85em;
  overflow-wrap: anywhere;
}

.mp-server {
  padding: 0 0 0.5rem;
}
.mp-table {
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--fg);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.mp-table div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10px auto;
  gap: 0.4rem;
  align-items: center;
}
.mp-table i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.mp-table b {
  color: var(--muted);
  font-weight: inherit;
}
.demo .mp-log {
  margin: 0.5rem 0 0;
  padding: 0 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
}
.demo .mp-log li {
  margin: 0;
}
.demo .mp-log li:last-child {
  color: var(--fg);
}

.mp-wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mp-msg {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--fg);
  border-radius: 999px;
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72em;
  white-space: nowrap;
  will-change: transform;
}
.mp-msg i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.mp-msg.mp-ack {
  border-color: var(--muted);
  color: var(--muted);
}

.mp-line {
  display: block;
}
.mp-line + .mp-line {
  margin-top: 0.3rem;
}
.mp-latest {
  color: var(--fg);
}

@container (max-width: 420px) {
  .mp-stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

/* Fractional indexing */
.demo .mp-layers {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.demo .mp-layers li {
  margin: 0;
}
.mp-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 0.6rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.mp-row.mp-drag {
  z-index: 1;
  border-color: var(--fg);
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.35);
  cursor: grabbing;
}
.mp-row.mp-new {
  border-color: var(--redline);
}
.mp-grip {
  padding: 0.4rem 0.1rem;
  color: var(--muted);
  letter-spacing: -0.2em;
  touch-action: none;
}
.mp-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.mp-name em {
  color: var(--redline);
  font-style: normal;
  font-size: 0.85em;
}
.demo .mp-row code {
  max-width: 14ch;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  background: none;
}

@media (prefers-reduced-motion: reduce) {
  .mp-shape {
    transition: none;
  }
}
