.flow-modal {
  display: flex;
  flex-direction: column;
  width: min(600px, calc(100% - 32px));
  height: min(650px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--modal);
  color: var(--text);
  outline: none;
  box-shadow: 0 18px 60px rgb(0 0 0 / 55%);
  overflow-y: auto;
}

.flow-modal::backdrop {
  background: var(--modal-backdrop);
}

.flow-modal--empty {
  min-height: min(320px, calc(100dvh - 32px));
}

.flow-modal--error {
  width: min(320px, calc(100% - 32px));
  height: auto;
  padding: 32px;
  border-radius: 16px;
  box-shadow: none;
}

.flow-modal--rules {
  width: min(640px, calc(100% - 32px));
  height: min(80dvh, calc(100dvh - 32px));
  overflow: hidden;
}

.flow-modal__header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  min-height: 52px;
  padding: 0 12px;
}

.flow-modal__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.flow-modal__close:disabled {
  opacity: 0.4;
  cursor: default;
}

.flow-modal__mark {
  justify-self: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
}

.flow-modal__error-header h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.flow-modal__body {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  padding: 8px 40px 32px;
}

.flow-modal__body--error {
  padding: 0;
}

.flow-modal__title {
  margin: 12px 0 24px;
  font-size: 1.8rem;
  line-height: 1.15;
}

.flow-form {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 16px;
}

.flow-form p,
.flow-field span,
.flow-check span {
  margin: 0;
  color: var(--text);
  line-height: 1.4;
}

.flow-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.flow-field input,
.flow-field select,
.flow-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--black);
  color: var(--text);
  font: inherit;
}

.flow-field textarea {
  min-height: 120px;
  resize: vertical;
}

.flow-field textarea.is-compact {
  min-height: 96px;
}

.flow-field input:focus,
.flow-field select:focus,
.flow-field textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.flow-check,
.flow-rules__agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.flow-recovery {
  align-self: flex-end;
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
}

.flow-rules-link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.flow-actions {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 32px;
}

.flow-button,
.flow-error__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.flow-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.flow-button--secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.flow-button--danger {
  background: var(--danger);
  color: #fff;
}

.flow-form-error {
  color: var(--danger);
}

.flow-error {
  display: grid;
  gap: 24px;
}

.flow-error p {
  margin: 0;
  color: #93a0ad;
  line-height: 1.35;
}

.flow-error__button {
  width: 100%;
  min-height: 44px;
  background: #f1f4f4;
  color: #0f1419;
}

.flow-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.flow-preview img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.flow-preview p {
  flex-basis: 100%;
}

.flow-spinner {
  display: grid;
  flex: 1;
  place-items: center;
  color: var(--muted);
}

.flow-rules {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 16px;
}

.flow-rules__agree {
  padding: 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

