.flow-demo {
  min-width: 0;
  padding: clamp(.75rem, 1.6vw, 1.3rem);
  border: 1px solid #554951;
  border-radius: var(--radius-layout-fixed-lg);
  background: linear-gradient(150deg, #302a32, #25242c);
  color: var(--on-dark);
  box-shadow: 0 1rem 3rem #0d0b124d;
}

.flow-demo [hidden] { display: none; }

.flow-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  padding: 3px;
  margin-bottom: var(--ref-space-3);
  border: 1px solid #48424c;
  border-radius: var(--radius-ui-md);
  background: #221f26;
}

.flow-demo button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-ui-sm);
  cursor: pointer;
  font: inherit;
  font-weight: var(--type-emphasis-strong);
}

.flow-tabs button {
  padding-inline: 2px;
  background: transparent;
  color: var(--muted-dark);
  font-size: .875rem;
}

.flow-tabs button:not([aria-selected="true"]):hover { color: var(--on-dark); }

.flow-tabs [aria-selected="true"] {
  background: #f6e9e3;
  color: #35252a;
}

.flow-demo .flow-replay {
  width: 44px;
  flex: none;
  border: 1px solid #63565d;
  background: #302b33;
  color: var(--on-dark);
  font-size: 1.375rem;
}

.flow-demo .flow-replay:hover { background: #443841; }

.flow-panel {
  display: grid;
  grid-template-rows: minmax(6.3rem, auto) 1.75rem minmax(10.1rem, auto);
}

.flow-message {
  padding: var(--ref-space-3) var(--ref-space-3-5);
  border: 1px solid #62515a;
  border-radius: var(--radius-ui-md);
  background: #3d333c;
}

.flow-message-type {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ref-space-1) var(--ref-space-2);
  margin-bottom: var(--ref-space-1);
  color: #ffb7a4;
  font-size: .875rem;
  font-weight: var(--type-emphasis-strong);
}

.flow-message blockquote { line-height: 1.48; }

.flow-message mark {
  border-radius: 3px;
  background: #64434a;
  color: #fff2eb;
}

.flow-wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}

.flow-wave span {
  width: 2px;
  height: var(--peak);
  border-radius: 2px;
  background: currentColor;
}

.flow-arrow {
  position: relative;
  width: 2px;
  height: 1.25rem;
  margin: .2rem auto 0;
  background: var(--coral);
}

.flow-arrow::after {
  position: absolute;
  right: -3px;
  bottom: 0;
  width: 8px;
  height: 8px;
  border: solid var(--coral);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  content: "";
}

.flow-result {
  padding: var(--ref-space-3-5);
  border: 1px solid #e9d1c6;
  border-radius: var(--radius-ui-md);
  background: #fff9f6;
  color: var(--ink);
}

.flow-result h2 {
  font-size: clamp(1.15rem, 2vw, 1.42rem);
  line-height: 1.15;
}

.flow-result .record-fields { margin-top: var(--ref-space-2); }
.flow-result .record-fields > div { border-color: #ebded8; }
.flow-result :focus-visible { outline-color: var(--accent-text); }

.flow-result .flow-confirm {
  margin-top: var(--ref-space-1-5);
  padding: 0 var(--ref-space-3);
  background: #f6e1d8;
  color: #63332b;
  font-size: .875rem;
}

.flow-confirm:not([aria-disabled="true"]):hover { background: #f3cbbd; }

.flow-result .flow-confirm[aria-disabled="true"] {
  background: #e7f0e8;
  color: #2f5838;
  cursor: default;
}

.flow-demo figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ref-space-2);
  margin-top: var(--ref-space-2);
  color: var(--muted-dark);
  font-size: .8rem;
}

@media (max-width: 26rem) {
  .flow-message, .flow-result { padding: var(--ref-space-2-5); }
}

@media (prefers-reduced-motion: reduce) {
  .flow-demo .flow-replay { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .flow-playing .flow-message { animation: flow-enter .32s ease-out both; }
  .flow-playing .flow-wave span { animation: flow-wave .42s ease-in-out calc(var(--beat) * .021s) 3; }
  .flow-playing mark { animation: flow-mark .36s ease-out .45s both; }
  .flow-playing mark:nth-of-type(2) { animation-delay: .58s; }
  .flow-playing mark:nth-of-type(3) { animation-delay: .71s; }
  .flow-playing .flow-arrow { animation: flow-enter .25s ease-out .59s both; }
  .flow-playing .flow-result { animation: flow-enter .35s ease-out .78s both; }
  .flow-playing .record-fields > div { animation: flow-enter .27s ease-out .9s both; }
  .flow-playing .record-fields > div:nth-child(2) { animation-delay: 1.02s; }
  .flow-playing .record-fields > div:nth-child(3) { animation-delay: 1.14s; }
  .flow-playing .flow-confirm { animation: flow-enter .27s ease-out 1.02s both; }
}

@keyframes flow-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes flow-mark {
  from { background: transparent; }
  to { background: #64434a; }
}

@keyframes flow-wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(.35); }
}

