.graph-viewport {
  background:
    radial-gradient(ellipse at 82% 70%, #e4d8f47a, transparent 42%),
    radial-gradient(ellipse at 22% 12%, #d5e7ffb3, transparent 46%),
    radial-gradient(circle, #a1b0cd5e 1px, transparent 1.45px) 0 0 / 22px 22px,
    #eef3fb;
}

#graph-stage {
  transition: transform .45s cubic-bezier(.22,.65,.25,1), top .45s cubic-bezier(.22,.65,.25,1);
}

#graph-stage .branch-card {
  --branch-accent: #526bb8;
  --branch-wash: #e3eaff;
  width: var(--card-width, 184px);
  height: var(--card-height, 78px);
  min-height: 0;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px 20px 9px 10px;
  border: 1px solid #ffffffdc;
  border-radius: 17px;
  background: linear-gradient(148deg, #ffffffec, #f0f4fce8);
  box-shadow: 0 8px 24px #43578820, inset 0 -1px 0 #8393b71a;
  color: var(--ink, #17233e);
  transition: border-color .24s, background .24s, box-shadow .24s;
}

#graph-stage .branch-card[data-root="true"] {
  --branch-accent: #4b57ac;
  --branch-wash: #dfe6ff;
  background: linear-gradient(147deg, #ffffff, #e4eafff2 77%, #eee4ffef);
  box-shadow: 0 11px 30px #5d6da72b, inset 0 -1px 0 #7785bd19;
}

#graph-stage .branch-card:is(:hover, [aria-pressed="true"]) {
  border-color: color-mix(in srgb, var(--branch-accent) 49%, white);
  background: linear-gradient(148deg, #fff, var(--branch-wash));
  box-shadow: 0 9px 22px #43578829, 0 0 0 2px #f3f6ffb3;
}

#graph-stage .branch-card[data-phase="delegated"] {
  --branch-accent: #7059ae;
  --branch-wash: #ebe3fc;
}

#graph-stage .branch-card:is([data-phase="tool"], [data-phase="checking"]) {
  --branch-accent: #166d7c;
  --branch-wash: #dff2f5;
}

#graph-stage .branch-card:is([data-phase="success"], [data-phase="verified"]) {
  --branch-accent: #287261;
  --branch-wash: #e5f3ee;
}

#graph-stage .branch-card[data-phase="error"] {
  --branch-accent: #a34460;
  --branch-wash: #fae8ef;
}

#graph-stage .agent-mark {
  margin: 0;
  align-self: center;
  width: 29px;
  height: 29px;
  color: var(--branch-accent);
  background: var(--branch-wash);
  border: 1px solid color-mix(in srgb, var(--branch-accent) 12%, white);
  border-radius: 10px;
  font-size: 14px;
  animation: none;
}

#graph-stage .agent-name {
  font-size: 12px;
  font-weight: 720;
  letter-spacing: -.015em;
}

#graph-stage .agent-status {
  margin-top: 5px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--branch-accent);
}

#graph-stage .agent-status::before { margin-right: 4px; }

.agent-effect {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 10px;
  height: 10px;
  pointer-events: none;
}

.agent-effect::before,
.agent-effect::after {
  position: absolute;
  inset: 1px;
  border: 1px solid var(--branch-accent);
  border-radius: 50%;
  opacity: 0;
  content: "";
}

.graph-viewport[data-live="true"] .branch-card:is([data-phase="thinking"], [data-phase="working"]) .agent-effect::before {
  opacity: .88;
  border-right-color: transparent;
  animation: axis-orbit 1.55s linear infinite;
}

.graph-viewport[data-live="true"] .branch-card:is([data-phase="tool"], [data-phase="delegated"], [data-phase="checking"]) .agent-effect::after {
  opacity: .65;
  animation: axis-breathe 1.8s ease-out infinite;
}

@keyframes axis-orbit { to { transform: rotate(1turn); } }
@keyframes axis-breathe {
  0% { transform: scale(.8); opacity: .9; }
  75%, 100% { transform: scale(1.9); opacity: 0; }
}

#graph-edges .edge {
  --branch-line: #9eafd0;
  --branch-packet: #607bc9;
}

#graph-edges .edge[data-phase="delegated"] { --branch-line: #aa94ce; }
#graph-edges .edge:is([data-phase="tool"], [data-phase="checking"]) { --branch-line: #76a8bb; }
#graph-edges .edge:is([data-phase="success"], [data-phase="verified"]) { --branch-line: #94bdb8; }
#graph-edges .edge[data-phase="error"] { --branch-line: #c793a7; }

#graph-edges .edge .edge-base {
  stroke: var(--branch-line);
  stroke-width: 1.8;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: stroke .28s;
}

#graph-edges .edge .edge-signal {
  stroke: var(--branch-packet);
  stroke-width: 3;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}

.edge-joint {
  fill: #f9fbff;
  stroke: var(--branch-line);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.event-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.event-facts div {
  padding: 8px 10px;
  border: 1px solid var(--line, #cfd8eb);
  border-radius: 9px;
  background: #f7f9fecc;
}

.event-facts dt { font-size: 10px; color: var(--muted, #4b5875); }
.event-facts dd { margin: 3px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.journal-details { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  #graph-stage,
  #graph-stage .branch-card,
  #graph-edges .edge .edge-base { transition: none; }
  .graph-viewport[data-live="true"] .branch-card .agent-effect::before,
  .graph-viewport[data-live="true"] .branch-card .agent-effect::after { animation: none; }
}
