:root {
  --paper: #ffffff;
  --ink: #1d1d1f;
  --accent: #c45c28;
  --mount: #f5f5f7;
  --chrome: #f5f5f7;
  --radius: 12px;
  --stamp: 5px 5px 0 #1d1d1f;
  --muted: #6e6e73;
  --soft: #d2d2d7;
  --track: #ececef;
  --fake: #c45c28;
  --real: #1d1d1f;
  --facts: #1d1d1f;
  --draft: #c45c28;
  --art: #86868b;
  --pass: #1d1d1f;
  --date: #c45c28;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--mount);
  color: var(--ink);
}

button {
  font: inherit;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--chrome);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 14px 18px 10px;
  flex-shrink: 0;
}

.tools {
  display: flex;
  gap: 8px;
}

.tool {
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  width: 40px;
  height: 36px;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--stamp);
  line-height: 1;
}

.tool.run {
  background: var(--accent);
  color: #fffaf5;
  border-color: var(--ink);
}

.tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.add-pop {
  position: absolute;
  top: 58px;
  left: 18px;
  z-index: 20;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 460px;
  padding: 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--stamp);
}

.add-pop.hidden {
  display: none;
}

.add-pop button {
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 16px 16px;
  border-radius: var(--radius);
  overflow: auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--stamp);
}

.canvas.connecting {
  cursor: crosshair;
}

.edges,
.nodes,
.hits {
  position: absolute;
  inset: 0;
  width: 1200px;
  height: 640px;
}

.edges {
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.nodes {
  position: relative;
  z-index: 3;
}

.hits {
  z-index: 6;
  pointer-events: none;
}

.edges .line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.edges .line.unknown {
  stroke: var(--ink);
  stroke-width: 2.5;
  opacity: 0.28;
}

.edges .line.unknown.mismatch {
  stroke: var(--accent);
  stroke-width: 4.5;
  stroke-dasharray: 11 9;
  opacity: 1;
  animation: warn 900ms ease-in-out infinite;
}

.edges .line.real {
  stroke: var(--ink);
  stroke-width: 3.5;
  opacity: 1;
}

.edges .line.false {
  stroke: var(--accent);
  stroke-dasharray: 6 10;
  opacity: 0.28;
}

.edges .line.flow {
  stroke-dasharray: 6 10;
  animation: dash 600ms linear infinite;
}

.edge-hit {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: transparent;
  font-size: 0;
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  opacity: 0.28;
}

.edge-hit.mismatch {
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  background: var(--accent);
  border: 2px solid var(--ink);
  color: #fffaf5;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  opacity: 1;
  box-shadow: var(--stamp);
  animation: pop-warn 900ms ease-in-out infinite;
}

.edge-hit.real {
  background: var(--ink);
  opacity: 1;
  box-shadow: none;
  animation: none;
}

.edge-hit.false {
  background: var(--accent);
  opacity: 0.28;
  box-shadow: none;
  animation: none;
}

.job {
  position: absolute;
  width: 176px;
  min-height: 96px;
  padding: 22px 24px 18px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--stamp);
  cursor: grab;
  user-select: none;
  z-index: 3;
  touch-action: none;
  transition: left 280ms ease, top 280ms ease;
}

.job.dragging {
  transition: none;
  z-index: 5;
}

.job:active {
  cursor: grabbing;
}

.job.verifier {
  border-radius: var(--radius);
}

.job.running {
  box-shadow: var(--stamp), 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.job.done {
  border-color: var(--ink);
}

.job.together {
  animation: hop 700ms ease;
}

.job.sending {
  box-shadow: var(--stamp), 0 0 0 3px var(--accent);
}

.job.fit {
  box-shadow: var(--stamp), 0 0 0 3px var(--ink);
}

.job.nope {
  opacity: 0.45;
}

.job.selected {
  box-shadow: var(--stamp), 0 0 0 3px var(--accent);
}

.remove {
  position: absolute;
  top: -8px;
  left: -8px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  opacity: 0;
  font-size: 10px;
  padding: 0;
}

.job:hover .remove {
  opacity: 1;
}

.remove:hover {
  color: var(--accent);
}

.job h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.03em;
}

.sockets {
  position: absolute;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(-50%);
  pointer-events: none;
}

.sockets.in {
  left: -7px;
}

.sockets.out {
  right: -7px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: transparent;
  display: block;
}

.dot.fill {
  background: currentColor;
}

.dot.facts,
.dot.pass {
  color: var(--ink);
}

.dot.draft,
.dot.date {
  color: var(--accent);
}

.dot.art {
  color: var(--art);
}

.meter {
  margin-top: 12px;
  height: 3px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
}

.job.running .meter span {
  animation: fill 800ms linear forwards;
}

.job.done .meter span {
  width: 100%;
}

.port {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  background: transparent;
  border: 0;
  z-index: 8;
  cursor: crosshair;
}

.port.in {
  left: -9px;
}

.port.out {
  right: -9px;
}

.rooms {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 7;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(440px, calc(100% - 32px));
  pointer-events: auto;
}

.room {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  min-height: 128px;
  padding: 12px;
  box-shadow: var(--stamp);
}

.lamp {
  float: right;
  width: 8px;
  height: 8px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--soft);
}

.room.writer[data-phase="live"] .lamp,
.room.writer[data-phase="done"] .lamp,
.room.clean[data-phase="live"] .lamp,
.room.clean[data-phase="done"] .lamp {
  background: var(--accent);
}

.tag {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.glyph {
  display: block;
  height: 10px;
  margin-bottom: 10px;
}

.glyph.chat {
  width: 28px;
  background:
    linear-gradient(var(--soft), var(--soft)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--soft), var(--soft)) 0 4px / 70% 2px no-repeat,
    linear-gradient(var(--soft), var(--soft)) 0 8px / 88% 2px no-repeat;
}

.glyph.tray {
  width: 22px;
  height: 14px;
  border: 2px solid var(--soft);
  border-radius: 3px;
  margin-bottom: 8px;
}

.mess,
.clean-body {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 54px;
}

.mess li {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--track);
  margin-bottom: 7px;
}

.mess li:nth-child(1) {
  width: 86%;
}

.mess li:nth-child(2) {
  width: 64%;
}

.mess li.bad {
  width: 72%;
  background: color-mix(in srgb, var(--accent) 45%, var(--paper));
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.packet {
  display: inline-block;
  width: 36px;
  height: 24px;
  margin: 0 8px 8px 0;
  border-radius: 5px;
  border: 2px solid var(--ink);
  animation: in 240ms ease;
}

.packet.facts {
  background: var(--paper);
}

.packet.draft {
  background: color-mix(in srgb, var(--accent) 18%, var(--paper));
  border-color: var(--accent);
}

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--paper);
  border: 3px solid var(--accent);
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  transform: rotate(-8deg);
  box-shadow: var(--stamp);
  animation: pop 280ms ease;
}

.room.clean[data-phase="done"] {
  box-shadow: var(--stamp);
}

@keyframes dash {
  to {
    stroke-dashoffset: -16;
  }
}

@keyframes fill {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes hop {
  40% {
    transform: translateY(-8px);
  }
}

@keyframes in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes pop {
  from {
    transform: rotate(-8deg) scale(0.72);
    opacity: 0;
  }
}

@keyframes warn {
  50% {
    opacity: 0.55;
    stroke-width: 6;
  }
}

@keyframes pop-warn {
  50% {
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}
