.agent-cycle {
  position: relative;
  margin: 1.7rem 0 0;
  padding: 1.25rem;
  border: 1px solid #d9dfe5;
  border-radius: 8px;
  background: #fbfcfd;
}

.agent-cycle:focus-visible {
  outline: 2px solid #87929c;
  outline-offset: 3px;
}

.cycle-orbit {
  position: relative;
  width: min(100%, 42rem);
  aspect-ratio: 1;
  margin: 0 auto;
}

.cycle-track {
  position: absolute;
  inset: 4.6rem;
  border: 1px solid #cbd2d8;
  border-radius: 50%;
}

.cycle-cursor {
  --cursor-angle: 0deg;
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 0.75rem;
  height: 0.75rem;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #303a44;
  box-shadow: 0 0 0 1px #303a44, 0 3px 10px rgba(48, 58, 68, 0.2);
  transform: translate(-50%, -50%) rotate(var(--cursor-angle)) translateY(-16.4rem);
  transition: transform 520ms ease;
}

.agent-cycle[data-step="1"] .cycle-cursor {
  --cursor-angle: 45deg;
}

.agent-cycle[data-step="2"] .cycle-cursor {
  --cursor-angle: 90deg;
}

.agent-cycle[data-step="3"] .cycle-cursor {
  --cursor-angle: 135deg;
}

.agent-cycle[data-step="4"] .cycle-cursor {
  --cursor-angle: 180deg;
}

.agent-cycle[data-step="5"] .cycle-cursor {
  --cursor-angle: 225deg;
}

.agent-cycle[data-step="6"] .cycle-cursor {
  --cursor-angle: 270deg;
}

.agent-cycle[data-step="7"] .cycle-cursor {
  --cursor-angle: 315deg;
}

.cycle-node {
  --node-angle: 0deg;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 0.38rem;
  width: 6rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: #596570;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  transform: translate(-50%, -50%) rotate(var(--node-angle)) translateY(-18.7rem) rotate(calc(-1 * var(--node-angle)));
}

.cycle-node-one {
  --node-angle: 0deg;
}

.cycle-node-two {
  --node-angle: 45deg;
}

.cycle-node-three {
  --node-angle: 90deg;
}

.cycle-node-four {
  --node-angle: 135deg;
}

.cycle-node-five {
  --node-angle: 180deg;
}

.cycle-node-six {
  --node-angle: 225deg;
}

.cycle-node-seven {
  --node-angle: 270deg;
}

.cycle-node-eight {
  --node-angle: 315deg;
}

.cycle-node-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid #cfd6dc;
  border-radius: 50%;
  background: #ffffff;
  color: #6f7b86;
  font-size: 1.15rem;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
}

.cycle-node:hover .cycle-node-icon,
.cycle-node:focus-visible .cycle-node-icon {
  border-color: #8c969f;
  color: #303a44;
  transform: scale(1.04);
}

.cycle-node:focus-visible {
  outline: 0;
}

.cycle-node.is-complete .cycle-node-icon {
  border-color: #aeb8c1;
  background: #f1f3f5;
  color: #3f4b55;
}

.cycle-node.is-active {
  color: #1f2932;
}

.cycle-node.is-active .cycle-node-icon {
  border-color: #303a44;
  background: #303a44;
  color: #ffffff;
  transform: scale(1.08);
}

.agent-cycle[data-step="5"] .cycle-node-six .cycle-node-icon {
  animation: background-pulse 1.4s ease-in-out infinite;
}

.cycle-output {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 20rem;
  height: 19rem;
  padding: 1rem;
  border: 1px solid #d9dfe5;
  border-radius: 8px;
  background: #fbfcfd;
  transform: translate(-50%, -50%);
}

.cycle-model {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #e1e5e9;
  color: #65717d;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.cycle-controls {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
}

.cycle-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid #cfd6dc;
  border-radius: 50%;
  background: #ffffff;
  color: #46535e;
  font-size: 0.85rem;
  line-height: 1;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.cycle-action:hover:not(:disabled),
.cycle-action:focus-visible,
.cycle-action[aria-pressed="true"] {
  border-color: #303a44;
  background: #303a44;
  color: #ffffff;
}

.cycle-action:focus-visible {
  outline: 2px solid #87929c;
  outline-offset: 2px;
}

.cycle-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.cycle-stream {
  flex: 1;
  min-height: 0;
  padding: 0.35rem 0;
  overflow-y: auto;
  scrollbar-color: #c2c9cf transparent;
  scrollbar-width: thin;
}

.cycle-stream-line {
  display: grid;
  grid-template-columns: 3.8rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.52rem 0;
  border-bottom: 1px solid #edf0f2;
  animation: cycle-stream-in 180ms ease-out both;
}

.cycle-stream-line:last-child {
  border-bottom: 0;
}

.cycle-stream-line > span {
  color: #7a858f;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1.55;
}

.cycle-stream-line p {
  margin: 0;
  color: #303a44;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.55;
}

.cycle-stream.is-streaming .cycle-stream-line:last-child p::after {
  display: inline-block;
  width: 0.08rem;
  height: 0.9em;
  margin-left: 0.18rem;
  background: #68747f;
  content: "";
  vertical-align: -0.08em;
  animation: cycle-caret 720ms steps(1, end) infinite;
}

@keyframes cycle-caret {
  50% {
    opacity: 0;
  }
}

.cycle-stream-line.is-tool p {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.69rem;
}

.cycle-stream-line.is-result > span,
.cycle-stream-line.is-memory > span {
  color: #46535e;
}

@keyframes cycle-stream-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.cycle-dish {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: center;
  min-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(0.35rem);
  transition: min-height 260ms ease, margin-top 260ms ease, opacity 260ms ease, transform 260ms ease;
}

.agent-cycle.is-finished .cycle-dish {
  min-height: 4.7rem;
  margin-top: 0.55rem;
  opacity: 1;
  transform: translateY(0);
}

@keyframes background-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(48, 58, 68, 0.2);
  }
  50% {
    box-shadow: 0 0 0 0.55rem rgba(48, 58, 68, 0);
  }
}

.dish-caption {
  color: #303a44;
  font-size: 0.8rem;
  font-weight: 800;
}

.dish-plate {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  border: 0.38rem solid #e5e9ec;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(44, 54, 62, 0.1);
}

.dish-egg,
.dish-tomato {
  position: absolute;
  display: block;
}

.dish-egg {
  width: 1.5rem;
  height: 1.15rem;
  border-radius: 55% 45% 52% 48%;
  background: #f2c94c;
}

.dish-egg-one {
  top: 0.65rem;
  left: 0.55rem;
  transform: rotate(-18deg);
}

.dish-egg-two {
  right: 0.45rem;
  bottom: 0.7rem;
  transform: rotate(22deg);
}

.dish-tomato {
  width: 1.15rem;
  height: 0.9rem;
  border-radius: 45% 55% 50% 46%;
  background: #d85c4a;
}

.dish-tomato-one {
  top: 0.55rem;
  right: 0.55rem;
  transform: rotate(16deg);
}

.dish-tomato-two {
  bottom: 0.55rem;
  left: 0.65rem;
  transform: rotate(-12deg);
}

.dish-tomato-three {
  top: 1.65rem;
  left: 1.45rem;
  transform: rotate(34deg);
}

@media (max-width: 767.98px) {
  .agent-cycle {
    margin-right: -0.1rem;
    margin-left: -0.1rem;
    padding: 0.7rem;
  }

  .cycle-orbit {
    width: 21rem;
    max-width: 100%;
  }

  .cycle-track {
    inset: 3.25rem;
  }

  .cycle-cursor {
    transform: translate(-50%, -50%) rotate(var(--cursor-angle)) translateY(-7.25rem);
  }

  .cycle-node {
    width: 4.3rem;
    gap: 0.25rem;
    font-size: 0.65rem;
    transform: translate(-50%, -50%) rotate(var(--node-angle)) translateY(-9.2rem) rotate(calc(-1 * var(--node-angle)));
  }

  .cycle-node-icon {
    width: 2.55rem;
    height: 2.55rem;
    font-size: 0.95rem;
  }

  .cycle-output {
    position: relative;
    top: auto;
    left: auto;
    width: min(100%, 24rem);
    height: 16rem;
    margin: 0.9rem auto 0;
    padding: 0.75rem;
    transform: none;
  }

  .cycle-model {
    font-size: 0.7rem;
  }

  .cycle-stream-line {
    grid-template-columns: 3.2rem minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.4rem 0;
  }

  .cycle-stream-line > span {
    font-size: 0.62rem;
  }

  .cycle-stream-line p,
  .cycle-stream-line.is-tool p {
    font-size: 0.71rem;
  }

  .agent-cycle.is-finished .cycle-dish {
    min-height: 3.8rem;
    gap: 0.4rem;
  }

  .dish-plate {
    width: 3.4rem;
    height: 3.4rem;
    border-width: 0.3rem;
    transform: scale(0.82);
    transform-origin: right center;
  }

  .dish-caption {
    margin-right: -0.45rem;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cycle-cursor,
  .cycle-node-icon,
  .cycle-dish {
    transition: none;
  }

  .agent-cycle[data-step="5"] .cycle-node-six .cycle-node-icon {
    animation: none;
  }
}
