.agent-scene-layout {
  display: grid;
  grid-template-columns: minmax(230px, .7fr) minmax(0, 1.42fr);
  align-items: center;
  gap: clamp(28px, 5.3vw, 80px);
}
.agent-task-flow { padding: 0; margin: 0; list-style: none; }
.agent-task-flow li { padding-block: 1.2rem; border-top: 1px solid var(--sub-line); }
.agent-task-flow li:first-child { border-color: var(--sub-ink); }
.flow-role { color: var(--sub-copy); font-size: .83rem; font-weight: 580; }
.agent-task-flow h3 { margin: .12rem 0 .45rem; font-size: clamp(1.15rem, 1.8vw, 1.45rem); line-height: 1.45; }
.agent-task-flow p { color: var(--sub-copy); line-height: 1.8; }

.agent-delegation {
  --af-ink: #273236;
  --af-rule: #859590;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  margin: 0;
  border: 1px solid #afbbb3;
  border-radius: 17px;
  background: #fafbf7;
  color: var(--af-ink);
}
.af-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 55px; padding: 9px clamp(15px, 2.4vw, 28px); border-bottom: 1px solid #d7dfd7; background: #f2f5ed; }
.af-toolbar strong { font-size: .98rem; }
.af-playback { display: inline-flex; align-items: center; gap: .46em; padding: .35rem .78rem; min-height: 35px; border: 1px solid #8b9990; border-radius: 999px; background: #fff; color: var(--af-ink); font-size: .85rem; font-weight: 600; cursor: pointer; }
.af-playback:hover { background: #e8f0de; }
.agent-delegation [hidden] { display: none !important; }
.af-control-icon { display: block; width: .7em; height: .8em; border-inline: 2px solid currentColor; }
.agent-delegation[data-playback="paused"] .af-control-icon { width: 0; height: 0; border: 0; border-block: .37em solid transparent; border-left: .62em solid currentColor; }
.agent-delegation[data-playback="ended"] .af-control-icon { width: .73em; height: .73em; border: 1.7px solid; border-right-color: transparent; border-radius: 50%; }

.af-diagram { display: grid; justify-items: center; padding: clamp(19px, 2.5vw, 36px) clamp(13px, 2.4vw, 36px); background-image: radial-gradient(#d9dfd4 .8px, transparent .9px); background-size: 16px 16px; }
.af-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(8px, 2vw, 26px); width: 100%; }
.af-node, .af-output { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 13px 16px; border: 1.5px solid #65716c; border-radius: 10px; background: #fff; }
.af-node { transition: background .25s, box-shadow .25s; }
.af-node strong, .af-output strong { display: block; font-size: 1rem; line-height: 1.5; }
.af-node small, .af-output small { display: block; margin-top: 2px; font-size: .83rem; line-height: 1.55; color: #475652; }
.af-lead { --af-agent: #dee4fe; --af-accent: #7067aa; }
.af-compute { --af-agent: #ffe09b; --af-accent: #997435; }
.af-research { --af-agent: #cceacc; --af-accent: #428768; }
.af-deck { --af-agent: #f4cddd; --af-accent: #a76580; }
.af-node.is-current { background: color-mix(in srgb,var(--af-agent) 25%,white); box-shadow: 0 0 0 2px var(--af-accent); }
.af-output.is-current { box-shadow: 0 0 0 2px #5a8160; }
.af-face {
  position: relative; display: block; flex: 0 0 42px; width: 42px; height: 36px;
  border: 1.7px solid var(--af-ink); border-radius: 9px 12px 8px 7px;
  background: var(--af-agent); box-shadow: 2px 2px 0 var(--af-ink); transform: rotate(-4deg);
}
.af-face::before, .af-face::after, .af-face > i::before, .af-face > i::after { content: ""; position: absolute; }
.af-face::before { left: 10px; top: 13px; width: 3px; height: 5px; border-radius: 50%; background: var(--af-ink); box-shadow: 14px 0 var(--af-ink); }
.af-face::after { width: 9px; height: 5px; left: 14px; top: 21px; border: 1.7px solid var(--af-ink); border-top: 0; border-radius: 0 0 8px 8px; }
.af-lead .af-face > i::before { width: 11px; height: 6px; top: -8px; left: 12px; border: 1.7px solid; border-radius: 5px 5px 0 0; background: var(--af-agent); }
.af-compute .af-face { border-radius: 5px; transform: rotate(4deg); }
.af-compute .af-face > i::before { height: 1px; top: 7px; left: 5px; right: 5px; background: var(--af-ink); }
.af-research .af-face { border-radius: 3px 8px 8px 3px; box-shadow: -3px 2px 0 #c3d5be,-4px 3px 0 var(--af-ink); }
.af-research .af-face > i::before { left: 3px; top: 1px; bottom: 1px; border-left: 1px solid #728e76; }
.af-deck .af-face { height: 31px; border-radius: 3px; transform: rotate(3deg); }
.af-deck .af-face::before { top: 9px; }
.af-deck .af-face::after { top: 17px; }
.af-deck .af-face > i::before { left: 18px; bottom: -7px; height: 6px; border-left: 2px solid; }
.af-deck .af-face > i::after { left: 11px; bottom: -8px; width: 16px; border-bottom: 2px solid; }

.af-wire { position: relative; width: calc(50% + clamp(8px, 2vw, 26px) / 2); height: 33px; }
.af-wire i { position: absolute; left: 0; right: 0; top: 37%; bottom: 0; border: 1.5px solid var(--af-rule); border-bottom: 0; border-radius: 7px 7px 0 0; }
.af-wire::before { content: ""; position: absolute; left: 50%; height: 37%; border-left: 1.5px solid var(--af-rule); }
.af-join { transform: scaleY(-1); }
.af-final-wire { position: relative; height: 26px; border-left: 1.5px solid var(--af-rule); }
.af-wire b, .af-final-wire b { display: none; position: absolute; width: 8px; height: 8px; background: #467354; border: 1px solid #fff; border-radius: 50%; }
.af-wire b:nth-child(2) { --af-end: 0%; }
.af-wire b:last-child { --af-end: 100%; }
.agent-delegation[data-phase="1"] .af-split b,
.agent-delegation[data-phase="2"] .af-join b { display: block; animation: af-route 1.6s linear infinite; }
.agent-delegation[data-phase="2"] .af-join b { animation-direction: reverse; }
.agent-delegation[data-phase="3"] .af-final-wire b { display: block; left: -4.5px; animation: af-drop 1.3s ease-in-out infinite; }
.agent-delegation[data-playback="paused"] b { animation-play-state: paused !important; }
.agent-delegation[data-playback="ended"] b { display: none; }
@keyframes af-route {
  0%, 12% { left: 50%; top: 0; opacity: 0; transform: translate(-50%,-50%); }
  23% { left: 50%; top: 37%; opacity: 1; }
  68% { left: var(--af-end); top: 37%; opacity: 1; }
  92%, 100% { left: var(--af-end); top: 100%; opacity: 0; transform: translate(-50%,-50%); }
}
@keyframes af-drop { 0% { top: 0; opacity: 0; } 35% { opacity: 1; } 100% { top: calc(100% - 4px); opacity: 0; } }

.af-output { background: #edf5ea; border-color: #93ac97; }
.af-sheet { display: inline-block; position: relative; flex: 0 0 32px; height: 39px; border: 1.5px solid #374838; border-radius: 3px; background: #fff; box-shadow: 2px 2px 0 #c0d5c1; transform: rotate(-4deg); }
.af-sheet::before, .af-sheet::after { content: ""; position: absolute; left: 5px; top: 6px; width: 14px; border-top: 2px solid #65796b; }
.af-sheet::after { top: 11px; width: 19px; border-top-width: 1px; }
.af-sheet i { position: absolute; left: 6px; bottom: 6px; width: 4px; height: 6px; background: #6e946c; box-shadow: 7px 0 #6e946c,14px 0 #6e946c; }
.af-sheet i::after { content: ""; position: absolute; left: 7px; bottom: 0; height: 10px; width: 4px; background: #6e946c; box-shadow: 7px -3px #6e946c; }

@media (max-width: 950px) {
  .agent-scene-layout { grid-template-columns: minmax(0,1fr); gap: 24px; }
  .agent-task-flow { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 20px; }
  .agent-delegation { grid-row: 1; }
}
@media (max-width: 600px) {
  .agent-task-flow { display: block; }
  .af-node, .af-output { gap: 9px; padding: 10px; }
  .af-pair .af-node { display: grid; align-content: start; justify-items: center; text-align: center; gap: 8px; padding-inline: 6px; }
  .af-pair { gap: 10px; }
  .af-node strong, .af-output strong { font-size: .94rem; }
  .af-node small, .af-output small { font-size: .79rem; }
  .af-wire { width: calc(50% + 5px); height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .af-node { transition: none; }
  .af-wire b, .af-final-wire b { animation: none !important; display: none !important; }
}
