.flow-container {
  padding: 16px;
  overflow: auto;
  min-height: 0;
}

.flow-diagram {
  container-type: inline-size;
  width: 100%;
  color: var(--ink);
}

.flow-context {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.flow-context > .icon {
  color: var(--green);
  flex-shrink: 0;
  margin-top: 2px;
}

.flow-context-note {
  color: #52635b;
  font-weight: 400;
}

.flow-local-chain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 33px minmax(0, 1fr) 45px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
}

.flow-card {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid #d3dfd7;
  border-top: 3px solid #8ea998;
  border-radius: 9px;
  background: #fff;
  overflow-wrap: anywhere;
}

.flow-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 9px;
  color: #496956;
}

.flow-card-number {
  font: 12px var(--mono);
  color: #53665c;
}

.flow-card h3 {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 4px;
  font-weight: 700;
}

.flow-card-description {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 12px;
  min-height: 38px;
  color: #52635b;
}

.flow-card-count {
  margin: 0 0 5px;
  font-size: 12px;
  color: #43594d;
  line-height: 1.5;
}

.flow-card-count strong {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.flow-card-state {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  color: #4d6356;
}

.flow-card-state.flow-changed {
  color: #815314;
  font-weight: 600;
}

.flow-step-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #516a5b;
  font: 12px var(--mono);
  border-radius: 6px;
}

.flow-step-arrow > .icon {
  width: 25px;
  height: 25px;
}

.flow-card.flow-current {
  border-color: #448467;
  background: #edf7f0;
}

.flow-step-arrow.flow-current {
  color: #116644;
  background: #e5f2e9;
  font-weight: 700;
}

.flow-return {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  margin: 12px 0 0;
  border-left: 3px solid var(--green);
  border-radius: 5px;
  background: #edf7f0;
  font-size: 12px;
  line-height: 1.6;
  color: #265b40;
}

.flow-return code,
.flow-transfer code {
  font: 12px/1.6 var(--mono);
  background: none;
  color: inherit;
  padding: 0;
}

.flow-remote {
  margin-top: 14px;
  border: 1px solid #dcd6e7;
  background: #faf8fd;
  border-radius: 9px;
  padding: 12px;
  color: #514266;
}

.flow-remote-heading {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.flow-remote-heading > .icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.flow-remote-heading > div {
  min-width: 0;
  flex: 1;
}

.flow-remote-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.flow-remote-heading h3 span {
  font-size: 12px;
  margin-left: 6px;
  font-weight: 400;
}

.flow-remote-heading p {
  font-size: 12px;
  line-height: 1.6;
  margin: 3px 0 0;
}

.flow-remote-count {
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

.flow-transfers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}

.flow-transfer {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid #ddd5e7;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  line-height: 1.6;
}

.flow-transfer code {
  font-weight: 700;
}

.flow-transfer.flow-current,
.flow-remote.flow-current {
  border-color: #8e73af;
  background: #f0eafa;
}

.flow-remote-note {
  margin: 9px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #60516f;
}

.flow-caption {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #eef5f0;
  border: 1px solid #d9e6dd;
  padding: 11px 12px;
  margin-top: 14px;
  border-radius: 8px;
  color: #31553e;
}

.flow-caption > .icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--green);
}

.flow-caption p {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.flow-caption .flow-replay {
  flex-shrink: 0;
  color: #315b43;
}

.flow-warning {
  background: #fff7e9;
  border-color: #ecd6b7;
  color: #77501b;
}

.flow-warning > .icon {
  color: #815314;
}

.flow-animate .flow-current {
  animation: flow-highlight 1.4s ease-out;
}

@keyframes flow-highlight {
  0%, 25% { box-shadow: 0 0 0 3px #91c9a3; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.motion-off .flow-animate .flow-current {
  animation: none;
}

@container (max-width: 450px) {
  .flow-local-chain {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .flow-card {
    display: grid;
    grid-template-columns: 27px minmax(0, 1fr) auto;
    gap: 2px 9px;
    padding: 11px 12px;
    border-top-width: 1px;
    border-left-width: 3px;
  }

  .flow-card-top {
    grid-column: 1;
    grid-row: 1 / 4;
    flex-direction: column;
    justify-content: flex-start;
    margin: 2px 0 0;
  }

  .flow-card h3 {
    grid-column: 2;
    margin: 0;
  }

  .flow-card-description {
    grid-column: 2;
    min-height: 0;
    margin: 0;
  }

  .flow-card-count {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    margin: 0;
    text-align: right;
  }

  .flow-card-state {
    grid-column: 2 / 4;
  }

  .flow-step-arrow {
    flex-direction: row;
    min-height: 26px;
    gap: 8px;
  }

  .flow-step-arrow > .icon {
    width: 20px;
    height: 20px;
    transform: rotate(90deg);
  }

  .flow-transfers {
    grid-template-columns: minmax(0, 1fr);
  }

  .flow-transfer {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .flow-remote-heading {
    flex-wrap: wrap;
  }

  .flow-remote-count {
    margin-left: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-animate .flow-current { animation: none; }
}
